当前位置: 代码迷 >> 综合 >> 解决'DataFrame' object has no attribute 'sort'
  详细解决方案

解决'DataFrame' object has no attribute 'sort'

热度:30   发布时间:2023-12-23 20:27:24.0

代码 

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

报错

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

解决

df.sort_values('shares',ascending=False)

注:

有时需要把    column=‘shares’ 改成 ‘shares’

  相关解决方案