Use split-apply-combine to calculate retention by cohort and period in pandas.
stat-tile-trio step-ladder before-after The raw table is event-grain, but the product question is customer retention by signup cohort and months since signup. Split by cohort and period only after converting event rows into customer-period observations, then apply distinct customer counts and combine with cohort sizes. Counting raw events is seductive because it runs fast and produces a dense table. It violates the retention question by allowing one highly active customer to count many times. Before Rows are product events. A customer with 20 events in month 2 contributes 20 counts. After Rows are customer-period flags. A customer active in month…
Sign up free — one personalized lesson every day, matched to your role and goals.
Already have an account? Sign in