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.
Latihan ini adalah bagian dari kursus
Python for Spreadsheet Users
Petunjuk latihan
- Use
.groupby()and.sum()to create a summary table bymovie_genre. - Use
.sort_values()and the proper arguments to sort byticket_quantityin descending order. - Print
genres_sorted.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
# 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