python - 模仿 spyder 排序列

标签 python python-3.x spyder

我有一个快速的问题:我正在使用 Spyder,变量浏览器选项卡中有一个巧妙的功能,我可以单击标题并对列进行排序。但是,当我尝试使用时无法重现相同的排序顺序:

df.sort_values()

在 python 中。我想知道是否有任何方法可以在 python 代码中重现 Spyder 排序的顺序。

最佳答案

如果你只是使用 df.sort_values() 它确实不起作用。

使用带有可选关键字 ascending=Falsedf.sort_values(COLUMN_NAMESTRING) 进行反向排序,将正常工作。

关于python - 模仿 spyder 排序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45619147/

相关文章:

python - Django:使用平面页面时找不到 flatpages/default.html

python - 无法处理一些关键的链接

python-3.x - 简单的语法在 Python 中给出 ValueError

python - 在远程服务器上运行 Spyder/Python

python - 在没有 Anaconda 的 Ubuntu 上的虚拟环境中运行 pip 安装的 Spyder?

Python Spyder 错误 TypeError : __init__() takes exactly 1 argument (2 given)

python - 使用 python、BeautifulSoup、mechanize 设置 HTML textarea 内容(没有表单,只有 div)

python - 如何以一种可以在单个命令中运行所有测试的方式组织 python 测试?

python - ValueError : Expected n_neighbors <= 1. Got 5 -Scikit K 最近分类器

python - 名称错误 : name 'GATE_OP' is not defined #tensorflow