CAC 2/2
CAC formula:
To write numbers in
0.0
format, use the next coderound(number, 1)
.
Compito
Swipe to start coding
- Create the
expenses
variable by finding the sum of allcost.
values. Use the.sum()
function. - Find the number of rows in the
df
and put this value into thecustomers_number
variable. - Define the
CAC
variable using the formula. - Print the
CAC
variable in the0.00
format.
Soluzione
99
1
2
3
4
5
6
7
8
9
10
11
12
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')
# Sum all expenses
expenses = df['cost'].sum()
# Find the number of rows
customers_number = df.shape[0]
# Define the CAC variable
CAC = expenses/customers_number
# Print the CAC value in 0.00 format
print('CAC =', round(CAC, 2))
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 4. Capitolo 5
99
1
2
3
4
5
6
7
8
9
10
11
12
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')
# Sum all expenses
expenses = ___['cost'].___()
# Find the number of rows
customers_number = ___.shape[0]
# Define the CAC variable
CAC = ___/___
# Print the CAC value in 0.00 format
___('CAC =', ___(___, 2))
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione