Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Is Our Project Profitable? ROI 1/2 | Becoming an Analyst
Introduction to Python for Data Analysis

book
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:

roi

  • Earnings , the sum of the column 'money_spent' .

  • Losses , the sum of the column 'cost' .

Завдання

Swipe to start coding

  1. Calculate the sum of the column df['cost'], and assign it to the variable cost_sum.
  2. Calculate the sum of the column df['money_spent'], and assign it to the variable spent_sum.
  3. Calculate ROI:
  • Subtract cost_sum from the spent_sum.
  • Divide the subtraction by the cost_sum.
  1. Output the ROI.

The result was already multiplied by 100 to get it in percentage.

Рішення

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
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
___(___)

Запитати АІ

expand
ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

some-alt