我从像数据框开始
print(df)
int float _i
1 2 2.000000e+00 1
3 3 3.000000e+00 3
2 3 4.000000e+00 2
4 -9223372036854775808 -1.797693e+308 4
0 -9223372036854775808 1.000000e+00 0
Run Code Online (Sandbox Code Playgroud)
如果我用sort_values两列排序,我得到你在下面看到的输出.所以sort_values似乎什么都不做.如果我只有一个列名它可以工作,我使用它的方式适用于以前的pandas版本.大熊猫有什么变化我不知道吗?
print(df.sort_values(["int", "float"]))
int float _i
1 2 2.000000e+00 1
3 3 3.000000e+00 3
2 3 4.000000e+00 2
4 -9223372036854775808 -1.797693e+308 4
0 -9223372036854775808 1.000000e+00 0
Run Code Online (Sandbox Code Playgroud)
在熊猫0.17.0我得到:
print(df.sort_values(["int", "float"]))
int float _i
4 -9223372036854775808 -1.797693e+308 4
0 -9223372036854775808 1.000000e+00 0
1 2 2.000000e+00 1
3 3 3.000000e+00 3
2 3 4.000000e+00 2
Run Code Online (Sandbox Code Playgroud)
最近的 pandas 版本不再显示此错误,不久前已修复: https://github.com/pandas-dev/pandas/commit/6bea8275e504a594ac4f ee71b5c941fb520c8b1a