ComenzarEmpieza gratis

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!

Este ejercicio forma parte del curso

Python for Spreadsheet Users

Ver curso

Instrucciones del ejercicio

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

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# 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
____
Editar y ejecutar código