如何基于两列对DataFrame进行排序?

时间:2018-06-14 17:24:54

标签: python python-2.7 pandas

我有一个数据框P2L

      Bucket  Cal. Month  Correlation Coefficient
0          0           3                 0.434191
1          1           3                 0.300000
104        0           4                 0.677849
105        1           4                 0.512215
504        0           5                 0.636996
505        1           5                 0.478503
896        0           6                 0.846745
897        1           6                 0.639870
1264       0           7                 0.784101
1265       1           7                 0.591472
1688       0           8                 0.684961
1689       1           8                 0.658894
2064       0           9                 0.796357
2065       1           9                 0.615737
2464       0          10                 0.758172
2465       1          10                 0.500315
2856       0          11                 0.577991
2857       1          11                 0.300000
3241       1          12                 0.346552
3242       0          12                 0.684050
3665       1           1                 0.556274
3666       0           1                 0.740597
4057       1           2                 0.328713
4058       0           2                 0.744560
4409       1           3                 0.300000
4410       0           3                 0.302623
4800       0           4                 0.358955
4801       1           4                 0.300000
5184       0           5                 0.330310
5185       1           5                 0.479765

我希望它有点像这样排序 -

      Bucket  Cal. Month  Correlation Coefficient
0          0           3                 0.434191
4800       0           4                 0.358955
4410       0           3                 0.302623
4058       0           2                 0.744560
3666       0           1                 0.740597
3242       0          12                 0.684050
2856       0          11                 0.577991
5184       0           5                 0.330310
2064       0           9                 0.796357
1688       0           8                 0.684961
2464       0          10                 0.758172
1264       0           7                 0.784101
104        0           4                 0.677849
896        0           6                 0.846745
504        0           5                 0.636996
1689       1           8                 0.658894
4801       1           4                 0.300000
1          1           3                 0.300000
4409       1           3                 0.300000
105        1           4                 0.512215
4057       1           2                 0.328713
3665       1           1                 0.556274
505        1           5                 0.478503
3241       1          12                 0.346552
2857       1          11                 0.300000
2465       1          10                 0.500315
897        1           6                 0.639870
2065       1           9                 0.615737
1265       1           7                 0.591472
5185       1           5                 0.479765

Bucket的排序方式为0到1.问题是所有Cal. Month值现在都处于混乱状态。如何按升序对它们进行排序,同时保持Bucket值按升序排列?

0 个答案:

没有答案