Topic Overview and Actualization

Today, we will explore sorting within a DataFrame using Python's pandas. We will delve into the sort_values() function, covering single and multi-column sorting and handling missing values.

Sample Dataset

Let's consider this small dataset containing statistics of basketball players:

Note that there is a tie in Points between "K. Durant" and "K. Bryant".

Learning How to Sort

We can sort DataFrame values using the sort_values() function.

In this example, the DataFrame is sorted by column Points in descending order using the by and parameters. Thus, we can list the most successful players in terms of average points scored.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal