We can use .idxmax to get the maximum value of a dataframe(df). My problem is that I have a df with several columns (more than 10), one of a column has identifiers of same value. I need to extract the identifiers with the maximum value:
>df
id value a 0 b 1 b 1 c 0 c 2 c 1
Now, this is what I'd want:
>df
id value a 0 b 1 c 2
I am trying to get it by using df.groupy(['id'])
, but it is a bit tricky:
df.groupby(["id"]).ix[df['value'].idxmax()]
Of course, that doesn't work. I fear that I am not on the right path, so I thought I'd ask you guys! Thanks!