0

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?

JoMcGee
  • 47
  • 8

1 Answers1

0

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)
QWERTYL
  • 1,355
  • 1
  • 7
  • 11
  • What if the Boolean values were a Series (i.e., a column in a dataframe)? How would I group together the occurrences of "True" and "False" by month to get the churn rate? – JoMcGee Nov 21 '22 at 23:56