'DataFrame' 对象没有属性 'sort' [英] 'DataFrame' object has no attribute 'sort'

查看:23
本文介绍了'DataFrame' 对象没有属性 'sort'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里遇到了一些问题,在我的 python 包中我已经安装了 numpy,但我仍然有这个错误:

I face some problem here, in my python package I have install numpy, but I still have this error:

'DataFrame' 对象没有属性 'sort'

任何人都可以给我一些想法..

Anyone can give me some idea..

这是我的代码:

final.loc[-1] =['', 'P','Actual']
final.index = final.index + 1  # shifting index
final = final.sort()
final.columns=[final.columns,final.iloc[0]]
final = final.iloc[1:].reset_index(drop=True)
final.columns.names = (None, None)

推荐答案

sort() 在 DataFrames 中被弃用,取而代之的是:

sort() was deprecated for DataFrames in favor of either:

sort() 在 Pandas 0.17 (2015-10-09) 版本中被弃用(但仍然可用),引入了 sort_values()sort_index().它在 0.20 版本 (2017-05-05) 中从 Pandas 中移除.

sort() was deprecated (but still available) in Pandas with release 0.17 (2015-10-09) with the introduction of sort_values() and sort_index(). It was removed from Pandas with release 0.20 (2017-05-05).

这篇关于'DataFrame' 对象没有属性 'sort'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆