使用 groupby 和 filter
groupby
filter
import pandas as pd df = pd.DataFrame({"A":["foo", "foo", "foo", "bar"], "B":[0,1,1,1], "C":["A","A","B","A"]}) df.groupby(["A", "C"]).filter(lambda df:df.shape[0] == 1)