Fix Python – ‘DataFrame’ object has no attribute ‘sort’


Asked By – Shi Jie Tio

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..

This is my code :

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

Now we will see solution for issue: ‘DataFrame’ object has no attribute ‘sort’


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

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).

This question is answered By – Brad Solomon

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0