← ALL WORK

INDEPENDENT PROJECT / SQL COHORTS + PANDAS / 2026 / 06

The first sale is
only the beginning.

A cohort view that keeps customer definitions and observation windows honest.

EXPLORE THE STORY ↓
23.65%weighted month-one retention

Only cohorts with a complete next month.

01

THE BUSINESS PROBLEM

Who returns after their first observed purchase?

A next-month return and a repeat purchase somewhere in the year answer different questions.

23.65%return in the next month

Mature cohorts only.

64.21%repeat within the analysis window

Identified customers with more than one eligible invoice.

02

WHAT I DID

From question
to useful work.

01

Group

Assign first-observed purchase cohorts with SQL CTEs.

02

Measure

Track monthly activity and leave future cells unobserved.

03

Validate

Rebuild in pandas and reconcile every cohort–age cell.

03

THE RESULTS

A retention baseline
you can test against.

Every SQL and pandas cohort count matches. The heatmap exposes timing and maturity instead of hiding them in one headline.

Retention, one cohort at a time.
Share of each first-observed cohort active in month M0–M11
CohortM0M1M2M3M4M5M6M7M8M9M10M11
2010-12100 percent37 percent32 percent38 percent36 percent40 percent36 percent35 percent35 percent40 percent37 percent50 percent
2011-01100 percent22 percent27 percent23 percent32 percent29 percent25 percent24 percent30 percent33 percent36 percent—
2011-02100 percent19 percent19 percent28 percent27 percent25 percent25 percent28 percent25 percent31 percent——
2011-03100 percent15 percent25 percent20 percent22 percent17 percent27 percent23 percent28 percent———
2011-04100 percent21 percent20 percent21 percent20 percent23 percent22 percent26 percent————
2011-05100 percent19 percent17 percent17 percent21 percent23 percent26 percent—————
2011-06100 percent17 percent16 percent26 percent23 percent33 percent——————
2011-07100 percent18 percent21 percent22 percent27 percent———————
2011-08100 percent21 percent25 percent24 percent————————
2011-09100 percent23 percent30 percent—————————
2011-10100 percent24 percent——————————
2011-11100 percent———————————

Percentages rounded for display. M0 = first observed purchase month. Blank future months are unobserved, not zero. Scroll the table on mobile.

THE BUSINESS TAKEAWAY

Use mature cohorts to design a first-to-second purchase experiment. Measure incremental lift with a control group.

THE EVIDENCE / GO DEEPER

LET’S DISCUSS YOUR PROJECT ↗
Methods, context & full project notes +

The business question

After a first observed purchase, how many customers return in the next month — and how does that differ from buying more than once over a full year?

The method

Created first-observed-purchase cohorts with SQL CTEs and monthly customer activity. Independently rebuilt the calculation in pandas, then reconciled every cohort/age cell. Unobserved future months remain blank rather than being treated as zero retention.

The result

Weighted month-one retention is 23.65% for cohorts with a complete next month. Across the full analysis window, 64.21% of identified customers have more than one eligible invoice. These answer different business questions; presenting them as interchangeable would be misleading.

A decision this can support

Use mature cohort trends to set a baseline for a first-to-second purchase experiment. Test whether reminders or onboarding help eligible first-time customers return, and evaluate incremental lift with a control group before claiming success.

Limits of the evidence.

“First observed” is not necessarily first-ever purchase. Earlier customer history is unavailable, so the first cohort is left-censored. Unidentified customers are excluded from retention, and the result cannot be generalised to them. The analysis is observational and does not measure a campaign effect.

Validation

SQL and pandas cohort counts match. Month-zero retention equals 100% for every cohort. All observed rates stay between 0% and 100%. The monthly trading pipeline also reconciles to the underlying line totals.

Data: Daqing Chen, Online Retail (2015), UCI. DOI 10.24432/C5BW33 · CC BY 4.0. Independent analysis of historical public data; recommendations have not been tested in a live business.

NEXT PROJECT / KEEP EXPLORING

Istanbul shopping ↗

YOUR NEXT MOVE

LET’S BUILD
SOMETHING USEFUL.