group by and get the first row in each pandas code example Example: select first row of every group pandas df.drop_duplicates(subset='A')