I am trying to get a kpi sorted from highest to lowest. I get them from the following:
df_partidos.groupby(['home']).agg({'away_score':[np.sum]}).head(10)
I would like to get the results of this kpi sorted from highest to lowest.
I have been looking with:
.sort_values( inplace=True, ascending=False)
But I haven't got any results. If someone can give me a hand
Good day,
You can use
df.sort_values()
to sort ascending or descending with one or multiple columnsInside the method
sort_values()
you must assign the column in the argumentby
If you want to sort descending you must use
df_matches.sort_values(by='col1', ascending=False)
If you want to sort with multiple columns then you should use a column array in
by
Full documentation is here