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

Conteúdo do Curso

Pandas: First Steps

Pandas: First Steps

1. Getting Started
2. Basics of Dataframes

book
Task: Calculating Total Sales Revenue

Tarefa

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.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 7
toggle bottom row

book
Task: Calculating Total Sales Revenue

Tarefa

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.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 7
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Sentimos muito que algo saiu errado. O que aconteceu?
some-alt