小编Gam*_*rms的帖子

如何对组进行排序,使第一行中的数字最大,第二行中的数字最小,第三行中的数字第二大,依此类推

所以我有一个这样的 df

In [1]:data= {'Group': ['A','A','A','A','A','A','B','B','B','B'],
    'Name': [ ' Sheldon Webb',' Traci Dean',' Chad Webster',' Ora Harmon',' Elijah Mendoza',' June Strickland',' Beth Vasquez',' Betty Sutton',' Joel Gill',' Vernon Stone'],
    'Performance':[33,64,142,116,122,68,95,127,132,80]}
In [2]:df = pd.DataFrame(data, columns = ['Group', 'Name','Performance'])

Out[1]:
    Group  Name             Performance
0    A     Sheldon Webb       33
1    A     Traci Dean         64
2    A     Chad Webster      142
3    A     Ora Harmon        116
4    A     Elijah Mendoza    122
5    A     June Strickland    68
6    B     Beth Vasquez       95
7    B     Betty …
Run Code Online (Sandbox Code Playgroud)

python sorting pandas columnsorting pandas-groupby

8
推荐指数
1
解决办法
293
查看次数

标签 统计

columnsorting ×1

pandas ×1

pandas-groupby ×1

python ×1

sorting ×1