哪部电影的平均销量最高
也许您还想知道,平均来看哪部电影卖出的票最多,这样一来,如果这部电影在您的另一家影院上映,您就能对它的表现有所预期。
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
____