1

I've grouped my dataframe by two variables, and know I want to select one single row for each Client ID by the max of Var1:

Start

Client ID  Channel   Var1
1              C      100
1              A      30
2              B      55
2              C      45

Output expected:

Client ID  Channel   Var1
1              C      100
2              B      55

How can I achieve this? I've tried with df.loc[df.groupby(['Client ID','Channel'], as_index=False)['Var1'].idxmax()], but it's not working

Thanks!

cs95
  • 379,657
  • 97
  • 704
  • 746
Charles
  • 43
  • 1
  • 6

0 Answers0