I have a dataframe with a binary column that is indicative of inactive customers (0 = active, 1 = inactive), similar to the following:
month customer_id inactive
2020-01 customer_1 0
2020-01 customer_2 0
2020-01 customer_3 0
2020-01 customer_3 0
2020-02 customer_1 0
2020-02 customer_1 0
2020-02 customer_2 0
2020-02 customer_2 0
2020-03 customer_2 1
2020-03 customer_3 1
2020-03 customer_4 0
2020-03 customer_4 0
2020-04 customer_1 0
2020-04 customer_1 1
2020-04 customer_4 0
2020-04 customer_5 0
To get a better way to view the total active customers, I want to make a cumulative count of unique customers per month that also subtracts the customers that have turned inactive. I am looking for an output that looks like this:
month cum_count_unique_customers
2020-01 3
2020-02 3
2020-03 2
2020-04 3
Is there a way to get that result using Pandas?
Thanks for the help!