dataframe rank groupby

Solutions on MaxInterview for dataframe rank groupby by the best coders in the world

showing results for - "dataframe rank groupby"
Mateo
21 Feb 2016
1>>> df["rank"] = df.groupby("group_ID")["value"].rank("dense", ascending=False)
2>>> df
3     group_ID item_ID  value  rank
40  0S00A1HZEy      AB     10     2
51  0S00A1HZEy      AY      4     3
62  0S00A1HZEy      AC     35     1
73  0S03jpFRaS      AY     90     1
84  0S03jpFRaS      A5      3     5
95  0S03jpFRaS      A3     10     2
106  0S03jpFRaS      A2      8     4
117  0S03jpFRaS      A4      9     3
128  0S03jpFRaS      A6      2     6
139  0S03jpFRaS      AX      0     7
14