哪一部電影的平均銷售最高
也許你也想知道,平均來看哪一部電影賣出的票最多,這樣當它在你的其他影城上映時,你就能預期表現如何。
theater_movie_summary 是一份依影城地點與電影片名彙整的摘要表,能幫你找出哪部電影的平均銷售最佳!
本練習屬於課程
給試算表使用者的 Python
練習說明
- 使用
.groupby()與.mean(),依movie_title建立平均票券銷售的摘要表。 - 以
ticket_quantity由大到小排序avg_sale_by_movie。 - 使用
.head()與print()印出movies_sorted的第一列。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# 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
____