Monthly Churn Rate from Subscriptions

medium
Unit 11 · Pandas IV0/3 to milestone

subs has one row per subscription with start and end dates (strings YYYY-MM-DD; end is None if still active). A subscription is active at the start of month M if start < M (first day) and (end is null or end >= M). It churns in month M if end falls within M.

Implement monthly_churn(subs, months) where months is a list like ["2024-02", "2024-03"], returning a DataFrame with columns month, active_start, churned, churn_rate (churned / active_start, rounded to 4 places; NaN if no actives). Only count churners who were active at the start of the month.

#pandas#churn#subscriptions2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Monthly Churn Rate from Subscriptions · TechGradify