Is Our Project Profitable? ROI 1/2
Is our project profitable? To figure this out, you can calculate one simple metric titled ROI; the formula is:
Earnings , the sum of the column
'money_spent'
.Losses , the sum of the column
'cost'
.
Завдання
Swipe to start coding
- Calculate the sum of the column
df['cost']
, and assign it to the variablecost_sum
. - Calculate the sum of the column
df['money_spent']
, and assign it to the variablespent_sum
. - Calculate
ROI
:
- Subtract
cost_sum
from thespent_sum
. - Divide the subtraction by the
cost_sum
.
- Output the
ROI
.
The result was already multiplied by 100 to get it in percentage.
Рішення
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import pandas as pd
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/783d7288-e86b-4b89-9966-a2fe97995277/section_3_dataset_upd.csv')
# Calculate the sum of cost
cost_sum = df['cost'].sum()
# Calculate the sum of money_spent
spent_sum = df['money_spent'].sum()
# Calculate ROI
ROI = ((spent_sum - cost_sum)/cost_sum)*100
# Output ROI
print(ROI)
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 4. Розділ 9
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import pandas as pd
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/783d7288-e86b-4b89-9966-a2fe97995277/section_3_dataset_upd.csv')
# Calculate the sum of cost
cost_sum = df['___'].___()
# Calculate the sum of money_spent
spent_sum = ___.___
# Calculate ROI
ROI = ((___ - ___)___)*100
# Output ROI
___(___)
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат