Pooled Versus Averaged Retention Across Countries for Instagram
Last updated: November 29, 2026
Quick Overview
Given per-country cohort sizes and retained counts for two months, write Python that computes the pooled retention rate, the unweighted mean of country rates, and the change at fixed country mix, showing how a shift in signup mix can make retention look worse when every country improved.
Meta
November 29, 20260
0
0 solved
Given per-country cohort sizes and retained counts for two months, write Python that computes the pooled retention rate, the unweighted mean of country rates, and the change at fixed country mix, showing how a shift in signup mix can make retention look worse when every country improved.
Instagram's growth reviews regularly see global retention fall while every major country is flat or up, because new signups shift toward lower-retention markets. This Python screen checks that a candidate aggregates ratios correctly and can separate mix shift from within-country change.
What the Interviewer Expects
- Compute the pooled rate as total retained over total cohort
- Explain why the unweighted mean of rates is not the global rate
- Compute a fixed-mix comparison using baseline weights
- Handle countries that appear in only one period
- Communicate the result in a sentence a PM can act on
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 you fully decompose the change into mix and rate components?
- Which weights would you pick for the fixed-mix number, and why?
- How does this relate to Simpson's paradox?
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
Input is {country: (cohort_size, retained)} for a before and after month. Retention here is Day-30 retention already counted upstream. Countries missing in one period are excluded from the fixed-mix...
Approach
Pooled rate is . The unweighted mean of rates treats a small country like a large one. The fixed-mix rate applies after-period country rates to before-period weights: $\sum_c w_c^...