Get the row corresponding to the max in pandas GroupBy [duplicate]

Check with sort_values +drop_duplicates

df.sort_values('B').drop_duplicates(['A'],keep='last')
Out[127]: 
   A  B  C
1  1  1  b
3  2  3  d

Leave a Comment