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
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Easy

0

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
ratio of sums
mix shift
weighted average
Simpson's paradox
Python dicts
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. 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 Problems
Sample 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 ∑rc/∑nc\sum r_c / \sum n_c. 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^...


Submit Your Answer
Markdown supported