开始使用免费开始使用

哪部电影的平均销量最高

也许您还想知道,平均来看哪部电影卖出的票最多,这样一来,如果这部电影在您的另一家影院上映,您就能对它的表现有所预期。

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
____
编辑并运行代码