ComenzarEmpieza gratis

What do seniors like?

Let's use what we've learned so far to create a summary table, sort for a specific subset of that table, sort the values, and print the most important results. We'll use these techniques to answer the question "what movies do seniors like best?"

Note that in this exercise, we'll group by a list directly in the .groupby() method, as opposed to the video exercise, where we first assigned a list to a variable.

Este ejercicio forma parte del curso

Python for Spreadsheet Users

Ver curso

Instrucciones del ejercicio

  • Group by movie_title and ticket_type to create movies_by_ticket_type.
  • Filter for where ticket_type is senior to create senior_ticket_movies.
  • Sort by ticket_quantity in descending order to create ordered_senior_movies.
  • Print the first 3 rows of ordered_senior_movies to the console.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# Summarize by movie title and ticket type
movies_by_ticket_type = sales.groupby(____, as_index=False).sum()

# Filter for senior tickets
senior_ticket_movies = movies_by_ticket_type[____[____] == ____].reset_index(drop=True)

# Sort senior ticket sales descending
ordered_senior_movies = senior_ticket_movies.____(____, ascending=____).reset_index(drop=True)

# Print the top 3 rows of the ordered table
____
Editar y ejecutar código