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.
Cet exercice fait partie du cours
Python for Spreadsheet Users
Instructions
- Use
.groupby()
and.sum()
to create a summary table bymovie_genre
. - Use
.sort_values()
and the proper arguments to sort byticket_quantity
in descending order. - Print
genres_sorted
.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de 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