Get startedGet started for free

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!

This exercise is part of the course

Python for Spreadsheet Users

View Course

Exercise 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().

Hands-on interactive exercise

Have a go at this exercise by completing this sample 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
____
Edit and Run Code