The pandas drop_duplicates function is great for \"uniquifying\" a dataframe. However, one of the keyword arguments to pass is take_last=True
pandas
drop_duplicates
take_last=True
use groupby and 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)