我有这样格式化的数据
df = pd.DataFrame(data=[['Steve', '3', '2'],
['Smith', '4', '3'],
['Scott', '0', '5'],
['Simon', '1', '8']],
columns=['Name', 'Count1', 'Count2'])
使用df.sort_values(by=['Count1','Count2'], ascending=[False,False], inplace=True)
进行排序,将会得到以下结果
Name Count1 Count2
1 Smith 4 3
0 Steve 3 2
3 Simon 1 8
2 Scott 0 5
我希望将任意列中最高个体值的行放在顶部。 这是我期望的输出结果:
Name Count1 Count2
3 Simon 1 8
2 Scott 0 5
1 Smith 4 3
0 Steve 3 2
如何适当地处理这个问题?