Python
#49

Calculate Monthly Churn and Retention Cohorts in Pandas

HardGoogle
Interview Question #49
Asked at Google

Given `active_users` (user_id, activity_month), write a function to calculate the churn rate percentage for each month.

Input Table: activity
3 rows preview
user_idmonth
12026-01
22026-01
12026-02
Expected Output Structure1 rows
monthchurn_rate_pct
2026-0150
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

Python 3.10 (Pandas)
Environment Ready

Click "Run & Test" to execute your Pandas code against the test assertions.

Chat with us