We will often find the need to sort our data by the values of one or many columns. Say we wanted to find the hottest days in New York City during October 2018; we could sort our values by the temp_C (or temp_F) column in descending order and use head() to select the number of days we wanted to see. To accomplish this, we can use the sort_values() method. Let's look at the top 10 days:
>>> df.sort_values(by='temp_C', ascending=False).head(10)
This shows us that October 7th was the warmest day during the month in October 2018, according to the LaGuardia station. Notice that we have ties between October 2nd and 4th and October 1st and 9th:
flags | datatype | date | station | temp_C | temp_C_whole | temp_F | temp_F_whole ... |
---|