📅  最后修改于: 2022-03-11 14:45:28.569000             🧑  作者: Mango
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