Calculate Monthly Churn

150 Views Asked by At

I am wanting to obtain a monthly customer churn rate by using the following formula:

(Number of Customers Lost within 1-month period / Number of Active Customers at the beginning of the 1-month period)

Say I have the following data (this is just a small sample of it - note that if "Boolean == True" the customer has left, otherwise False)

start_date Boolean
2015-10-02 False
2015-10-04 False
2015-10-05 True
2015-10-06 True
2015-10-08 True
2015-10-08 True
2015-10-08 False
2015-10-08 False
2015-10-08 True
2015-10-08 False

What I would like to do is use the above-stated formula to obtain a time-series graph to plot the monthly customer churn overtime (which would be the monthly customer churn across all years in the dataset)

How would I go about doing this?

1

There are 1 best solutions below

1
On

Assuming you have the data stored in an array:

Boolean = [False, False, True, True, True, True, False, False, True, False]

the solution is a simple one-liner:

sum([1 for x in Boolean if x])/len(Boolean)