Which movie averages the most sales
Maybe you're also curious on average which movie sells the most tickets, so you would know what to expect of that movie should it start playing in another one of your theaters.
theater_movie_summary is a summary of theater location and movie titles that will help you find which movie is averaging the best sales!
Latihan ini adalah bagian dari kursus
Python for Spreadsheet Users
Petunjuk latihan
- Use
.groupby()and.mean()to create a summary table of average ticket sales bymovie_title. - Sort
avg_sale_by_moviebyticket_quantityin descending order. - Print the first line of
movies_sortedusing.head()andprint().
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
# Summary of movies and locations
theater_movie_summary = sales.groupby(['theater_location', 'movie_title'], as_index=False).sum()
# Get average ticket sales by movie title
avg_sale_by_movie = theater_movie_summary.____(____, as_index=False).____()
# Sort average ticket sales in descending order
movies_sorted = avg_sale_by_movie.____(____, ascending=False).reset_index(drop=True)
# Print results
____