python - Streamlit - TypeError:sort_index()得到了一个意外的关键字参数'ignore_index'
问题描述
我正在尝试使用以下行对索引进行排序。
task_count_20.sort_index(ascending=False, ignore_index=True, inplace=True)
上面的代码行在Google colab
本地环境中工作,但是当我尝试使用 构建应用程序时streamlit
,我收到以下回溯错误。
TypeError: sort_index() got an unexpected keyword argument 'ignore_index'
Traceback:
File "app.py", line 601, in <module>
Lollipop_count_plot(df, col, count=20)
File "app.py", line 209, in Lollipop_count_plot
task_count_20.sort_index(ascending=False, ignore_index=True, inplace=True)#
在 pandas 官方文档中,sort_index()
有关键字ignore_index
pandas.DataFrame.sort_index
DataFrame.sort_index(axis=0, level=None, ascending=True, inplace=False, kind='quicksort', na_position='last', sort_remaining=True, ignore_index=False, key=None)
解决方案
从文档中,我找到了ignore_index
1.0.0 版的新功能。
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.sort_index.html
也许您需要检查pandas
库版本。
推荐阅读
- python - Python 上的连接检查器脚本
- django - Djongo 支持固定装置吗?
- css - Safari 不显示第一个具有显示的元素:列中的 inline-flex 和 box-shadow
- git - 已删除的文件是否会显示在通过 GitHub 发布的包中?
- node.js - 一次运行 2 个 npm 命令
- gcc - 在运行 64 位 linux 的 Armv8 (aarch64) 上编译并运行 32 位二进制文件
- reactjs - 如何使用 minikube 在 kubernetes 上部署 React 和 Django REST 框架?
- javascript - 从选定的文本创建元素
- x-cart - Xcart 4 - 添加到帮助菜单但不在主页上的静态页面内容工作
- python - 在python中迭代和比较两个列表