To sort Python Pandas dataframe from one column, we call sort_values
.
For instance, we write
final_df = df.sort_values(by=['2'], ascending=False)
to call sort_values
with the by
argument set to ['2']
to sort by column 2.
And we set ascending
to False
to sort the items by column 2 in descending order.