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

Contenu du cours

Pandas: First Steps

Pandas: First Steps

1. Getting Started
2. Basics of Dataframes

book
Task: Calculating Total Sales Revenue

Tâche

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.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 7
toggle bottom row

book
Task: Calculating Total Sales Revenue

Tâche

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.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 7
Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Nous sommes désolés de vous informer que quelque chose s'est mal passé. Qu'est-il arrivé ?
some-alt