Visualize ROI
In the previous chapter, we calculated ROI daily, which will help us recognize the unprofitable day. Indeed, if we know that Monday is unprofitable, we should spend less money to attract users, for example!
It is tough to conclude without graphs, so visualize ROI!
Завдання
Swipe to start coding
- Create
barplot
with the arguments:
df
as thedata
parameter.'day'
column for x-axis.'ROI'
column for y-axis.
- Output
barplot
Рішення
99
1
2
3
4
5
6
7
8
9
10
11
12
13
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# You've already calculated ROI by week days
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/783d7288-e86b-4b89-9966-a2fe97995277/section_3_dataset_upd.csv')
df = df[['day', 'cost', 'money_spent']].groupby('day').sum().reset_index()
df['ROI'] = ((df['money_spent'] - df['cost'])/ df['cost'])*100
# Create barplot
sns.barplot(data = df, x = 'day', y = 'ROI')
# Output barplot
plt.show()
Congratulations! We figured out that Monday and Thursday are the most unprofitable days. Further, it is fantastic to find out whether these two days are similar or if we are making the same mistake on Monday and Thursday. But to do it, you should continue learning courses that will help you to become a Data Analyst.
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 4. Розділ 11
99
1
2
3
4
5
6
7
8
9
10
11
12
13
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# You've already calculated ROI by week days
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/783d7288-e86b-4b89-9966-a2fe97995277/section_3_dataset_upd.csv')
df = df[['day', 'cost', 'money_spent']].groupby('day').sum().reset_index()
df['ROI'] = ((df['money_spent'] - df['cost'])/ df['cost'])*100
# Create barplot
___.___(data = ___, x = ___, y = ___)
# Output barplot
___
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат