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
This is much easier in pandas now with drop_duplicates and the keep parameter.
import pandas as pd df = pd.DataFrame({"A":["foo", "foo", "foo", "bar"], "B":[0,1,1,1], "C":["A","A","B","A"]}) df.drop_duplicates(subset=['A', 'C'], keep=False)