セクション 2. 章 7
single
Task: Calculating Total Sales Revenue
メニューを表示するにはスワイプしてください
タスク
スワイプしてコーディングを開始
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
dfby 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.5which 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.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 2. 章 7
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください