一、排序
1、索引排序
a.sort_index(axis = 1 ,ascending=False)
Out[103]:
4 3 2 1 0
0 4 3 2 1 0
1 9 8 7 6 5
2 14 13 12 11 10
3 19 18 17 16 15a.sort_index(axis = 1 ,ascending=False).sort_index(axis=0,ascending=False)
Out[107]:
4 3 2 1 0
3 19 18 17 16 15
2 14 13 12 11 10
1 9 8 7 6 5
0 4 3 2 1 0
2、值排序
a.sort_index(axis = 1 ,ascending=False)
Out[103]:
4 3 2 1 0
0 4 3 2 1 0
1 9 8 7 6 5
2 14 13 12 11 10
3 19 18 17 16 15a.sort_values(2,axis = 1,ascending=False)
Out[110]:
4 3 2 1 0
0 4 3 2 1 0
1 9 8 7 6 5
2 14 13 12 11 10
3 19 18 17 16 15
二、数据基本统计分析
a
Out[111]:
0 1 2 3 4
0 0 1 2 3 4
1 5 6 7 8 9
2 10 11 12 13 14
3 15 16 17 18 19
a.describe()
Out[112]:
0 1 2 3 4
count 4.000000 4.000000 4.000000 4.000000 4.000000
mean 7.500000 8.500000 9.500000 10.500000 11.500000
std 6.454972 6.454972 6.454972 6.454972 6.454972
min 0.000000 1.000000 2.000000 3.000000 4.000000
25% 3.750000 4.750000 5.750000 6.750000 7.750000
50% 7.500000 8.500000 9.500000 10.500000 11.500000
75% 11.250000 12.250000 13.250000 14.250000 15.250000
max 15.000000 16.000000 17.000000 18.000000 19.000000
三、累计统计分析函数
1、累计统计函数
a
Out[113]:
0 1 2 3 4
0 0 1 2 3 4
1 5 6 7 8 9
2 10 11 12 13 14
3 15 16 17 18 19
a.cumsum()
Out[114]:
0 1 2 3 4
0 0 1 2 3 4
1 5 7 9 11 13
2 15 18 21 24 27
3 30 34 38 42 46
a.cumprod()
Out[115]:
0 1 2 3 4
0 0 1 2 3 4
1 0 6 14 24 36
2 0 66 168 312 504
3 0 1056 2856 5616 9576
a.cummax()
Out[116]:
0 1 2 3 4
0 0 1 2 3 4
1 5 6 7 8 9
2 10 11 12 13 14
3 15 16 17 18 19
a.cummin()
Out[117]:
0 1 2 3 4
0 0 1 2 3 4
1 0 1 2 3 4
2 0 1 2 3 4
3 0 1 2 3 4
2、滚动统计函数
#默认为 axis=0
a.rolling(2).sum()
Out[121]:
0 1 2 3 4
0 NaN NaN NaN NaN NaN
1 5.0 7.0 9.0 11.0 13.0
2 15.0 17.0 19.0 21.0 23.0
3 25.0 27.0 29.0 31.0 33.0