開始使用免費開始

哪一部電影的平均銷售最高

也許你也想知道,平均來看哪一部電影賣出的票最多,這樣當它在你的其他影城上映時,你就能預期表現如何。

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
____
編輯並執行程式碼