Measure YouTube Premium Churn by Signup Channel With Censoring in Pandas
Last updated: November 29, 2026
Quick Overview
Given a DataFrame of YouTube Premium subscriptions with signup date, signup channel and an optional cancel date, compute 30-day and 90-day churn rates per channel, counting only subscribers observed long enough to be judged.
0
0
0 solved
Given a DataFrame of YouTube Premium subscriptions with signup date, signup channel and an optional cancel date, compute 30-day and 90-day churn rates per channel, counting only subscribers observed long enough to be judged.
A pandas question in the style of Google's data science technical screens, framed around YouTube Premium acquisition channels (free trial, family plan invite, direct paid). The interviewer is mainly checking whether you notice right censoring: recent signups cannot have churned within 90 days yet.
What the Interviewer Expects
- Compute tenure from signup to cancel date or to the as-of date
- Restrict each horizon to subscribers with at least that many days observed
- Define churn at horizon h as cancelling before h days of tenure
- Aggregate per channel with counts as well as rates
- Explain why including recent signups biases churn downward
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would a Kaplan-Meier curve improve on this fixed-horizon approach?
- Trial users who never convert to paid: are they churn? How would you define it?
- Channel mix shifted toward trials last quarter. How do you compare channels fairly?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
subs has one row per subscription: user_id, signup_date, signup_channel, cancel_date (NaT if still active). Data is as of a given date. I assume one subscription per user; if users resubscribe, I ...
Approach
For each horizon h, keep only subscribers whose signup is at least h days before the as-of date, because a user who signed up 7 days ago has had no chance to churn by day 90 and would look retained. W...