Answers for "nlargest of each group"

0

nlargest of each group

df.groupby('team').apply(lambda x:x.nlargest(3,'points')).reset_index(drop=True)

  team   player  points
0    A    Alice      15
1    A   Carmen      13
2    A    Becky      11
3    B    Greta      29
4    B     Fran      28
5    B     Iris      25
6    C     Lucy      23
7    C    Molly      18
8    C  Ophelia      15
Posted by: Guest on October-30-2021

Code answers related to "nlargest of each group"

Python Answers by Framework

Browse Popular Code Answers by Language