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 seniorsticket_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!
This exercise is part of the course
Python for Spreadsheet Users
Exercise instructions
- Use the
.merge()
method onticket_type_sales
to join theticket_prices
DataFrame on theticket_type
column. - Create a
revenue
column insales_complete
that equalstickets_sold
multiplied byticket_price
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Join the tables
sales_complete = ticket_type_sales.____(____, ____, ____)
# Add a revenue column
____ = ____ * ____
# Print the table
print(sales_complete)