MulaiMulai sekarang secara gratis

Merging for ticket prices

So it turns out our tickets for adults, children, and seniors cost different dollar amounts!

Currently loaded are two DataFrames:

  • ticket_type_sales - A summary of tickets sold to adults, children, and seniors
  • ticket_prices - A table of how much tickets cost for each ticket type

Feel free to check them out in the console to get a better understanding of them.

Let's merge ticket_type_sales with ticket_prices to calculate revenue by ticket type!

Latihan ini adalah bagian dari kursus

Python for Spreadsheet Users

Lihat Kursus

Petunjuk latihan

  • Use the .merge() method on ticket_type_sales to join the ticket_prices DataFrame on the ticket_type column.
  • Create a revenue column in sales_complete that equals tickets_sold multiplied by ticket_price.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Join the tables
sales_complete = ticket_type_sales.____(____, ____, ____)

# Add a revenue column
____ = ____ * ____

# Print the table
print(sales_complete)
Edit dan Jalankan Kode