备案 控制台
学习
实践
活动
专区
工具
TVP
写文章
专栏首页 python前行者 'DataFrame' object has no attribute 'sort'
3 0

海报分享

'DataFrame' object has no attribute 'sort'

原码

import tushare as ts
df = ts.profit_data(top=60)
df.sort('shares',ascending=False)

报错

AttributeError:'DataFrame' object has no attribute 'sort'

解决:将“sort”改为“sort_values”

import tushare as ts
df = ts.profit_data(top=60)
df.sort_values('shares',ascending=False)
本文参与 腾讯云自媒体分享计划 ,欢迎热爱写作的你一起参与!
本文分享自作者个人站点/博客: https://blog.csdn.net/xc_zhou/ 复制
如有侵权,请联系 cloudcommunity@tencent.com 删除。