LoslegenKostenlos loslegen

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!

Diese Übung ist Teil des Kurses

Python for Spreadsheet Users

Kurs anzeigen

Anleitung zur Übung

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

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# 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
____
Code bearbeiten und ausführen