Sub topic 8
Pitfalls: incomplete periods, small cohorts, and mixed users
This chapter assumes you can already build a cohort retention table, as in the earlier chapter, and can read a retention curve. You should be comfortable with pandas groupby, unstack, and basic proportions. The goal is to learn the three ways a correct-looking table most often misleads you, and how to check for each one before you draw a conclusion about product-market fit.
Why a correct table can still mislead
A cohort table is arithmetic on event data. The arithmetic can be right while the reading is wrong, because the table does not show three things:
- how much time each cohort has had to be observed,
- how many users each cell is based on,
- what kinds of users each cohort contains.
Each gap produces a characteristic false story. Incomplete periods make the product look like it is losing users at the edge of the table. Small cohorts make random noise look like a trend. Mixed users make a change in who signed up look like a change in the product.
Pitfall 1: incomplete periods
What goes wrong
Retention is measured at a given age, such as month 2. A cohort has only reached that age if enough calendar time has passed. Cells for ages that have not happened yet must be treated as unknown, not as zero.
There are two versions of this error.
- Unobserved cells filled with zero.
unstack(fill_value=0)turns missing combinations into0. A cohort that simply has not reached month 3 then appears to have lost everyone. Averaged into a column mean, these zeros drag the whole curve down at later ages. - A partial current period. If your data ends on the 20th, the current month holds only 20 days of activity. Users in that month are undercounted. The newest cohort looks small, and every cohort's most recent cell looks weak.
The second error is harder to spot, because the cell is not empty. It holds a real number that is too low.
The fix
Choose an as_of period, the last period that is fully observed. Treat a cell as observed only if the cohort's start plus its age is at or before as_of. Mask the rest with NaN.
import numpy as np
import pandas as pd
def build_retention(events: pd.DataFrame) -> pd.DataFrame:
events = events.copy()
events["month"] = events["ts"].dt.to_period("M")
events["cohort"] = events.groupby("user_id")["month"].transform("min")
events["age"] = (events["month"] - events["cohort"]).apply(lambda d: d.n)
active = (
events.groupby(["cohort", "age"])["user_id"]
.nunique()
.unstack(fill_value=0)
)
return active.div(active[0], axis=0)
def mask_incomplete(retention: pd.DataFrame, as_of: pd.Period) -> pd.DataFrame:
max_age = np.array([(as_of - c).n for c in retention.index])
observed = retention.columns.to_numpy()[None, :] <= max_age[:, None]
return retention.where(observed)
events = pd.DataFrame({
"user_id": [1, 1, 1, 2, 2, 3, 3, 4, 5, 5],
"ts": pd.to_datetime([
"2026-01-05", "2026-02-10", "2026-03-03",
"2026-01-20", "2026-02-15",
"2026-02-02", "2026-03-12",
"2026-02-18",
"2026-03-05", "2026-03-20",
]),
})
retention = build_retention(events)
# Data ends on 2026-03-20, so March is only partly observed.
# The last complete month is February.
as_of = pd.Period("2026-02", freq="M")
print(mask_incomplete(retention, as_of).round(2))With as_of set to February, the January cohort keeps ages 0 and 1, and its month-2 value is masked. The February cohort keeps only age 0. The March cohort disappears entirely, because its own starting month is incomplete.
Edge cases
- Choose
as_offrom the data, not from the clock. If your pipeline lags by a few days, today's date overstates what you have. Use the latest timestamp you trust, then step back one period if it falls mid-period. - Time zones. A user whose event falls just after midnight UTC may land in a different month than in your product's local time. Pick one zone and keep it for the whole analysis.
- Rolling definitions need the same care. Rolling retention ("active at age N or later") is biased upward for young cohorts, because later activity has had no chance to appear yet. Compare rolling numbers only between cohorts of equal observed age.
Pitfall 2: small cohorts
What goes wrong
A retention percentage is a proportion, and a proportion from few users is noisy. If a cohort has 6 users and 3 return, retention is 50%. If one more user had returned, it would be 67%. A single person moves the cell by 17 points. That is not a product change.
Small cohorts are common in early-stage products, in narrow segments, and in the oldest cells of any table, where only the earliest cohorts reach.
Quantify the uncertainty
Attach a confidence interval to each proportion. The Wilson interval behaves well for small counts and for proportions near 0 or 1, unlike the simple normal approximation.
import numpy as np
def wilson(k: int, n: int, z: float = 1.96) -> tuple[float, float]:
if n == 0:
return (np.nan, np.nan)
p = k / n
denom = 1 + z**2 / n
center = (p + z**2 / (2 * n)) / denom
half = z * np.sqrt(p * (1 - p) / n + z**2 / (4 * n**2)) / denom
return center - half, center + half
for k, n in [(3, 6), (300, 600)]:
lo, hi = wilson(k, n)
print(f"{k}/{n} = {k / n:.0%}, 95% interval {lo:.0%} to {hi:.0%}")Both cohorts show 50%. The 6-user cohort has an interval of about 19% to 81%, which is compatible with almost any story. The 600-user cohort has an interval of about 46% to 54%.
Practical responses
- Show counts next to percentages. Keep the cohort size (the age-0 count) as a column in every table you share.
- Pool adjacent cohorts. Combine weekly cohorts into monthly ones, or monthly into quarterly, until each group has a defensible size. Pooling trades time resolution for stability.
- Set a floor. Decide a minimum cohort size before looking at results, for example 100 users for headline claims, and grey out cells below it. A threshold chosen after seeing the data invites cherry-picking.
- Watch the multiple-comparison trap. A table has many cells. Some will look unusual by chance. Look for patterns across several cells and cohorts, not single outliers.
Pitfall 3: mixed users
What goes wrong
A cohort groups users by when they started. It says nothing about who they are. If different types of users retain very differently, the blended retention depends on the mix of types, and the mix can change from cohort to cohort even when the product does not.
Common sources of mix change:
- a marketing campaign that brings in many low-intent visitors,
- a new acquisition channel, such as a partner or a viral referral,
- a launch in a new country or customer size,
- internal accounts, test accounts, and bots counted as real users,
- reactivated users who count as new because your cohort rule only looks at the first event in a recent window.
A worked example
Two cohorts each contain 100 users. Casual users retain at 10% by month 3 and power users at 60%, in both cohorts. Only the mix differs.
import pandas as pd
cohorts = pd.DataFrame({
"cohort": ["2026-01", "2026-01", "2026-02", "2026-02"],
"segment": ["casual", "power", "casual", "power"],
"users": [80, 20, 20, 80],
"retained_m3": [8, 12, 2, 48],
})
by_segment = cohorts.assign(rate=cohorts["retained_m3"] / cohorts["users"])
print(by_segment)
blended = cohorts.groupby("cohort")[["users", "retained_m3"]].sum()
blended["rate"] = blended["retained_m3"] / blended["users"]
print(blended)The blended month-3 retention rises from 20% in January to 50% in February. Within each segment, nothing changed: casual users stay at 10% and power users at 60%. A team reading only the blended table would celebrate an improvement that never happened. The reverse also occurs: a real improvement can be hidden when a growth campaign dilutes the mix. This is Simpson's paradox in a cohort setting.
What to do
- Clean the population first. Exclude employees, test accounts, and known bots before building any table.
- Split by an attribute fixed at signup. Channel, plan, country, company size, and device are safe choices. Do not split by behavior that happens after the starting event, such as "users who invited a teammate". That behavior is partly a result of staying, so the split makes retention look better than it is.
- Check composition across cohorts. Print the share of each segment per cohort next to the retention table. A large shift in shares is a warning.
- Compare like with like. When judging whether the product is improving, compare the same segment across cohorts.
Summary of the three pitfalls
| Pitfall | What you see | Quick check | Fix |
|---|---|---|---|
| Incomplete periods | Newest cells and diagonal edge look weak, or zeros appear | Compare each cell's age with the data's last complete period | Mask with `NaN` using an `as_of` period |
| Small cohorts | Jumpy values, one cohort differs sharply from neighbors | Look at age-0 counts and Wilson intervals | Pool cohorts, set a minimum size, show intervals |
| Mixed users | Blended retention shifts without a product change | Print segment shares per cohort | Clean the population and split by signup attributes |
Order of checks
Run the checks in this order. Masking incomplete periods comes first, because it removes cells that should not be read at all. Cohort size comes second, because it tells you how much weight each remaining cell can bear. Composition comes last, because it needs enough users per segment to be meaningful. After all three, a pattern that remains, such as a curve that flattens or a steady improvement across cohorts, deserves your trust far more than the raw table did.
Exercise
Your data ends on 18 April. A table shows the March cohort at 42% retention at month 1 (April), while the February cohort showed 55% at month 1 (March). A colleague says the product got worse. Which pitfall should you check first, and how?
Show answer
Incomplete periods. April is only 18 days observed, so the March cohort's month-1 cell is undercounted. Set as_of to the last complete month (March), mask every cell whose cohort start plus age is after March, and compare again. March's month-1 value should then be masked rather than compared with February's.
Exercise
A cohort of 12 users has 7 retained at month 3 (58%), while the previous cohort of 400 users had 50%. Is the new cohort better? Name two things you would do before deciding.
Show answer
You cannot tell. With 12 users the 95% interval is very wide (roughly 32% to 81%) and includes 50%. Compute a Wilson interval for the new cohort, and either pool it with neighboring cohorts or wait for more users. Also print the segment shares for both cohorts, in case the small cohort is simply a different mix of users.
Exercise
A team splits its cohorts into "users who invited a teammate" and "users who did not", finds the first group retains far better, and concludes that the product fits invited users. What is wrong with this split?
Show answer
Inviting a teammate happens after signup and is partly a result of staying engaged, so users who left early had less chance to invite anyone. The split builds in survivorship and exaggerates the difference. Split by attributes known at signup, such as channel, plan, or company size, and treat early behavior as a hypothesis to test, not as a segment.