'DataFrame'对象没有属性'sort' [英] 'DataFrame' object has no attribute 'sort'
本文介绍了'DataFrame'对象没有属性'sort'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里遇到了一些问题,在我的python包中,我已经安装了numpy,但是仍然出现此错误'DataFrame'对象没有属性'sort'
I face some problem here, in my python package I have install numpy, but I still have this error 'DataFrame' object has no attribute '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_values()
按列排序 -
sort_index()
到按索引排序
sort_values()
to sort by column(s)sort_index()
to sort by the index
sort()
在Pandas中已弃用(但仍可用),其中引入了sort_values()
和sort_index()
,发行版为0.17(2015-10-09).它已从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屋!
查看全文