且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

pandas 按两列分组后对列进行排序

更新时间:2022-12-09 22:38:11

可以通过sort本身进行分组和组内排序:

You can perform the grouping and the in-group sorting through sort itself:

df1 = df.sort_values(['Election Year','Region', 'Vote %'], ascending=False)