Explore retention and churn
Now that you have calculated the monthly retention and churn metrics for monthly customer cohorts, you can calculate the overall mean retention and churn rates. You will use the .mean()
method twice in a row (this is called "chaining") to calculate the overall mean. You will have to exclude the first month values (first column) from this calculation as they are constant given this is the first month the customers have been active therefore their retention will be 100% and churn will be 0% for all cohorts.
The pandas
and numpy
libraries have been loaded as pd
as np
respectively. The retention
and churn
monthly datasets that you built in the previous exercises are also imported.
This exercise is part of the course
Machine Learning for Marketing in Python
Exercise instructions
- Calculate the mean retention rate.
- Calculate the mean churn rate.
- Print rounded retention and churn rates.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Calculate the mean retention rate
retention_rate = retention.iloc[:,1:].mean().___()
# Calculate the mean churn rate
churn_rate = churn.iloc[:,1:].mean().___()
# Print rounded retention and churn rates
print('Retention rate: {:.2f}; Churn rate: {:.2f}'.format(___, churn_rate))