2019-04-11
阅读量:
998
Python按行对DataFrame排序
data = {"b":[4,7,-3,2,2,2],"a":[9,2,5,1,0,7],"c":[6,5,8,3,4,4]}
frame = pandas.DataFrame(data,columns = ['b','a','c'])
frame
Out[90]:
b a c
0 4 9 6
1 7 2 5
2 -3 5 8
3 2 1 3
4 2 0 4
5 2 7 4
按行升序
frame.sort_index(axis = 1,ascending = True)
Out[91]:
a b c
0 9 4 6
1 2 7 5
2 5 -3 8
3 1 2 3
4 0 2 4
5 7 2 4
按行降序
frame.sort_index(axis = 1,ascending = False)
Out[97]:
c b a
0 6 4 9
1 5 7 2
2 8 -3 5
3 3 2 1
4 4 2 0
5 4 2 7






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论