Pandas Retention Matrix for WhatsApp Business Signups by Channel

Last updated: November 29, 2026

Quick Overview

Given pandas DataFrames of WhatsApp Business signups (with acquisition channel) and daily activity, build a table indexed by channel and signup week with cohort size and the share of each cohort active in weeks 0 through N since signup, leaving immature cells as NaN.

Meta
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Given pandas DataFrames of WhatsApp Business signups (with acquisition channel) and daily activity, build a table indexed by channel and signup week with cohort size and the share of each cohort active in weeks 0 through N since signup, leaving immature cells as NaN.

Meta data science screens increasingly allow Python, and a WhatsApp Business growth question about which acquisition channel retains small businesses is a natural fit. The interviewer is looking for idiomatic pandas (merge, groupby, unstack), correct week offsets relative to each user's own signup, and careful treatment of censored cells.

What the Interviewer Expects
  • Compute week offset relative to each user's signup date
  • Deduplicate to one row per user per week
  • Reindex so cohorts with zero returners still appear
  • Distinguish a true 0 from a not-yet-observable NaN
  • Keep cohort size beside the rates
Key Topics to Cover
pandas groupby
unstack
cohort analysis
censoring
merge
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 plot this so channels are comparable?
  • What changes if a business can have several phone numbers?
  • How would you test whether the paid-ads channel retains significantly worse?
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

signups(user_id, signup_date, channel) with one row per business account; activity(user_id, event_date) with many rows. Weeks since signup use each user's own signup date (days // 7). The last obs...

Approach

Merge activity onto signups, compute week_n, keep weeks 0..N, drop duplicate (user, week) pairs, count users per (channel, cohort_week, week_n), unstack weeks into columns and divide by cohort size....


Submit Your Answer
Markdown supported