Task: Calculating Total Sales Revenue
Swipe to start coding
At Café Pandasia, the manager wants to calculate the total revenue for each coffee drink sold over three days.
You’ve been given the following DataFrame (df
) tracking the sales for each coffee drink across three days (Monday to Wednesday).
Coffee | Monday | Tuesday | Wednesday |
---|---|---|---|
Espresso | 45 | 38 | 50 |
Latte | 60 | 65 | 62 |
Cappuccino | 30 | 28 | 35 |
Additionally, you have the prices for each coffee drink stored in a separate DataFrame (prices
):
Coffee | Price |
---|---|
Espresso | 2.5 |
Latte | 2.7 |
Cappuccino | 3.0 |
- Add a new column "Total Revenue" to the original
df
by calculating the total revenue for each coffee drink. - The total revenue is the sum of the sales from Monday to Wednesday, multiplied by the price of the respective drink. For example, for Espresso, the total revenue will be
(45 + 38 + 50) x 2.5
which is equal to332.5
.
Note
The solution to this task is very similar to the previous one. The only diffierence is an additional multiplication. Recall how to multiply the corresponding values of two series, the same method applies to the dataframes.
Løsning
Takk for tilbakemeldingene dine!
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Oppsummer dette kapittelet
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 2.7
Task: Calculating Total Sales Revenue
Sveip for å vise menyen
Swipe to start coding
At Café Pandasia, the manager wants to calculate the total revenue for each coffee drink sold over three days.
You’ve been given the following DataFrame (df
) tracking the sales for each coffee drink across three days (Monday to Wednesday).
Coffee | Monday | Tuesday | Wednesday |
---|---|---|---|
Espresso | 45 | 38 | 50 |
Latte | 60 | 65 | 62 |
Cappuccino | 30 | 28 | 35 |
Additionally, you have the prices for each coffee drink stored in a separate DataFrame (prices
):
Coffee | Price |
---|---|
Espresso | 2.5 |
Latte | 2.7 |
Cappuccino | 3.0 |
- Add a new column "Total Revenue" to the original
df
by calculating the total revenue for each coffee drink. - The total revenue is the sum of the sales from Monday to Wednesday, multiplied by the price of the respective drink. For example, for Espresso, the total revenue will be
(45 + 38 + 50) x 2.5
which is equal to332.5
.
Note
The solution to this task is very similar to the previous one. The only diffierence is an additional multiplication. Recall how to multiply the corresponding values of two series, the same method applies to the dataframes.
Løsning
Takk for tilbakemeldingene dine!
Awesome!
Completion rate improved to 2.7single