0

I have a dataframe. It is group by 'ex' as below: enter image description here Now I want to get rows which have max value in each group

1 Answers1

1

so a quick google search and you will find out how to get relevant rows here: for your implementation:

df.groupby("ex")['transaction_fee'].max()

the other thing you should look for is how to get the corresponding indices for the original table. you could find something similar here:

for your implemtionation:

idxs = df.groupby("ex")['transaction_fee'].transform(max) == df['transaction_fee']
relevant_df = df[idxs]

cheers ✌

shai gindin
  • 109
  • 3