DataFrame.sort_values(by=‘##’,axis=0,ascending=True, inplace=False, na_position=‘last’)
by:按哪一列为主
ascend:从上到下为从小到大
axis:若axis=1或’columns’,则按照指定索引中数据大小排序,默认axis=0
x = pd.DataFrame({'x1':[1,2,2,3],'x2':[4,3,2,1],'x3':[3,2,4,1]})
print(x)
#按照索引值为0的行,即第一行的值来降序排序
print(x.sort_values(by =0,ascending=False,axis=1))
>>>
x1 x2 x3
0 1 4 3
1 2 3 2
2 2 2 4
3 3 1 1
x2 x3 x1
0 4 3 1
1 3 2 2
2 2 4 2
3 1 1 3