Aller au contenu principal

Build a Cohort Retention Table

Use split-apply-combine to calculate retention by cohort and period in pandas.

python-for-data-analysis5 min read

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…

Read the full lesson

Sign up free: one personalized lesson every day, matched to your role and goals.

← Back to library

Nous contacter