Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Task: Calculating Total Sales Revenue | Basics of Dataframes
Pandas: First Steps

Stryg for at vise menuen

book
Task: Calculating Total Sales Revenue

Opgave

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).

CoffeeMondayTuesdayWednesday
Espresso453850
Latte606562
Cappuccino302835

Additionally, you have the prices for each coffee drink stored in a separate DataFrame (prices):

CoffeePrice
Espresso2.5
Latte2.7
Cappuccino3.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 to 332.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

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 7

Spørg AI

expand
ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

book
Task: Calculating Total Sales Revenue

Opgave

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).

CoffeeMondayTuesdayWednesday
Espresso453850
Latte606562
Cappuccino302835

Additionally, you have the prices for each coffee drink stored in a separate DataFrame (prices):

CoffeePrice
Espresso2.5
Latte2.7
Cappuccino3.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 to 332.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

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 7
Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Vi beklager, at noget gik galt. Hvad skete der?
some-alt