How to sort values using Pandas• 1 min
Pandas has a method called .sort_values() which gives the user an easy to sort any column in a Pandas DataFrame
We define a sample DataFrame
You can download it here if the above script doesn't work for you and read it like so
One column sorting
It is by default in the ascending order, if you want the reverse you can use the ascending parameter.
Two columns sorting
It is possible to sort by one or more columns.
Python will take the first column as primary filter then will use the second as secondary filter, etc...
In order to perform a two or more columns sorting, you will need to put the columns of interest within a list.
Here you are ! You now know how to sort values using Pandas.