Skip to content
skillbld
Day 7 of 14 30 minsort_values()nlargest()rank()

Put data in order and find what stands out. Sort by one or several columns, sort by the index, get the top or bottom rows with nlargest() and nsmallest(), and number rows with rank(), including how it handles ties.

By the end of today you can

  • Sort rows by one or several columns with sort_values()
  • Control direction per column and where missing values go
  • Restore order with sort_index()
  • Get the top or bottom N rows with nlargest() and nsmallest()
  • Rank values with rank() and choose how ties are handled

What's inside

  • 5 sections
  • 3 diagrams and mind maps
  • 7 code examples you can run
  • 5-question quiz
  1. 1sort_values(): order by a column
  2. 2Sorting by several columns
  3. 3sort_index(): back to the original order
  4. 4nlargest() and nsmallest(): top and bottom N
  5. 5rank(): position numbers

Sign in free to read this lesson

Get the full lesson with diagrams, runnable code and the quiz. Your progress is saved across devices.

Sign in free
Day 7: Sorting & Ranking · Data Analysis with pandas · SkillBld