0

I want to sort this dataframe by values of "Score"(from giggest to smalles or vice versa, I just want some order here) I coded at end: models.sort_values(by='Score', ascending=False)

                        Model     Score
0     Support Vector Machines  0.685315
1                         KNN  0.748252
2         Logistic Regression  0.769231
3               Random Forest  0.944056
4                 Naive Bayes  0.769231
5                  Perceptron  0.720280
6  Stochastic Gradient Decent  0.447552
7                  Linear SVC  0.790210
8               Decision Tree  0.727273

Obviously my code didn't work, what should I write?

0

1 Answer 1

2

sort_values is not in-place by default. From the docs:

DataFrame.sort_values(by, axis=0, ascending=True, inplace=False, kind='quicksort', na_position='last')

Either use inplace=True:

models.sort_values(by='Score', ascending=False, inplace=True)

Or re-assign:

models = models.sort_values(by='Score', ascending=False)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.