In this section, we will learn about the pandas sort_values method. We will also use various methods to sort a pandas DataFrame and learn how to sort a pandas series object.
We will start by importing the pandas module and reading the dataset of house prices from zillow.com into the Jupyter Notebook. First, let's start with the simple type of sorting. We will use pandas' sort_values method for this. For example, imagine that we want to sort the data by the Metro column. We need to pass Metro as a parameter to the sort_values method, and call the method on the DataFrame as follows:
This shows that the data has been sorted by the Metro column, as shown in the following screenshot: