Klausos Klausos
Klausos Klausos

Reputation: 16050

DataFrame object has no attribute 'sort_values'

dataset = pd.read_csv("dataset.csv").fillna(" ")[:100]
dataset['Id']=0
dataset['i']=0
dataset['j']=0
#...
entries=dataset[dataset['Id']==0]
print type(entries)  # Prints <class 'pandas.core.frame.DataFrame'>
entries=entries.sort_values(['i','j','ColumnA','ColumnB'])

What might be the possible reason of the following error message at the last line?:

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

Upvotes: 23

Views: 79433

Answers (2)

Gagan
Gagan

Reputation: 71

Check pandas version, In new versions uses sort_values in place of sort.

Upvotes: 3

Romain
Romain

Reputation: 21948

Hello sort_values is new in version 0.17.0, so check your version of pandas. In the previous versions you should use sort.

entries=entries.sort(['i','j','ColumnA','ColumnB'])

Upvotes: 28

Related Questions