pandas でテーブルを結合した後のレコードのカウント方法を調査してみました。 both コード まとめ right_only コード まとめ right_only コード まとめ both コード import pandas as pd df = pd.DataFrame({ "_merge": ["both", "left_only", "both", "both"], "XXX_ID": [1, 2, 1, 3] }) # 重複含む "both" の数 print(int((df["_merge"] == "both").sum())) # → 3 # XXX_ID ベースで重複除外し…