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

Kursinhalt

Pandas: First Steps

Pandas: First Steps

1. Getting Started
2. Basics of Dataframes

book
Task: Calculating Total Sales Revenue

Aufgabe

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ösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 2. Kapitel 7
toggle bottom row

book
Task: Calculating Total Sales Revenue

Aufgabe

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ösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 2. Kapitel 7
Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
Wir sind enttäuscht, dass etwas schief gelaufen ist. Was ist passiert?
some-alt