BaşlayınÜcretsiz Başlayın

.groupby() and .sum() together

If you looked at our transaction-level data in the last exercise, you may have noticed some new columns, like movie_genre and ticket_type. In this exercise, we'll focus on summarizing our data by ticket_type. Tickets can be priced for adults, seniors, or children, and the ticket_type column contains the ticket type purchased during each transaction.

Let's use .groupby() and .sum() to create a summary table to understand how many of our tickets are of each ticket type.

The pandas package and the sales dataset has already been loaded for you.

Bu egzersiz

Python for Spreadsheet Users

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Use .groupby() and .sum() to create a summary table of ticket sales by ticket_type.
  • Print the result, ticket_type_summary, to the console.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create summary by ticket type
ticket_type_summary = sales.____(____, as_index=False).____()

# Print ticket_type_summary
Kodu Düzenle ve Çalıştır