CommencerCommencer gratuitement

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!

Cet exercice fait partie du cours

Python for Spreadsheet Users

Afficher le cours

Instructions

  • Use .groupby() and .mean() to create a summary table of average ticket sales by movie_title.
  • Sort avg_sale_by_movie by ticket_quantity in descending order.
  • Print the first line of movies_sorted using .head() and print().

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# 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
____
Modifier et exécuter le code