0

I have a DF that looks like the following table

Name Year
Alice 2019
Bob 2020
John 2021
Bob 2022

I would like for each unique 'Name' to check which 'Year' is higher and drop the row with the lower 'Year'. For example can I drop the row with 'Bob' containing 'Year' 2021 without stating the year specifically?

I tried using df.drop_duplicates('Name') but it is dropping the rows not the way I want to. And also tried with np.where() and pd.groupby() functions but couldn't figure out a way.

0 Answers0