Get startedGet started for free

Summarizing and sorting values

We can take what we've learned so far to create tables that give us informative views into our data.

Through grouping and summing, we can condense our data down to the features we really care about. Then with methods like .sort_values(), we can order that data to learn more.

Let's get a better look at what movie_genres are yielding the highest ticket sales.

This exercise is part of the course

Python for Spreadsheet Users

View Course

Exercise instructions

  • Use .groupby() and .sum() to create a summary table by movie_genre.
  • Use .sort_values() and the proper arguments to sort by ticket_quantity in descending order.
  • Print genres_sorted.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create a summary by movie genre 
genre_summary = sales.____(____,as_index=False).____()

# Sort summary in descending order of tickets sold
genres_sorted = genre_summary.____(____, ____).reset_index(drop=True)

# Print the sorted summary
Edit and Run Code