Sorting

Sort DataFrames based on their column features.

Chapter Goals:

  • Learn how to sort a DataFrame by its features
  • Write code to sort an MLB player's statistics

A. Sorting by feature

When we deal with a dataset that has many features, it is often useful to sort the dataset. This makes it easier to view the data and spot trends in the values.

In pandas, the sort_values function allows us to sort a DataFrame by one or more of its columns. The first argument is either a column ...