…
…
Clean the dirty member records and join them with the branch data; track churn, measure the effect of the flex plan with difference-in-differences and regression, and write the executive summary.
FitCampus is a gym chain with six branches in Port Alder. Member loss is management's biggest worry: about 7 percent of the members leave every month. In January 2026, three branches (Old Town, Harborside, Tech Park) tried a flex plan: all members at these branches can freeze their membership for up to two months instead of canceling it. The other three branches (Midtown, West End, Eastfield) continued as before.
At the end of June 2026 the board will decide: Did the flex plan reduce member loss, and should it be rolled out to all branches? In this project you will do the whole analysis yourself, from cleaning the member records to writing the executive summary.
Data:
| File | Columns | Description |
|---|---|---|
branches.csv | branch_id, branch, district, flex_plan | Six branches; flex_plan = 1 for a pilot branch |
members_raw.csv | member_id, branch, signup_date, age, plan, monthly_fee, avg_monthly_visits, cancel_date | Members who were active for at least one day since 2025; taken from the membership system as it is (dirty). If cancel_date is empty, the member is still active |
branch_monthly.csv | branch_id, month, active_start, new, churned, total_visits | For each branch and month from July 2025 to June 2026: active members at the start of the month, new sign-ups, members who left, and total visits |
The values are sample data.
Lessons used: cleaning (12-14), merging and grouping (9-11), charts (20-21), business metrics and time series (37-38), chi-square (33), multiple regression (36), difference-in-differences and fallacies (40), reporting (41-42).
Cells create new tables instead of changing the tables of earlier cells, so running a cell again does not break the result.
What you'll do
branches.csvDownload file
Reading file…
members_raw.csvDownload file
Reading file…
branch_monthly.csvDownload file
Reading file…
Code cells are for members
You can read the steps. Sign up free to run the code, complete the steps and save your progress.
Read the three files and check their sizes. In the member list, count the missing values, the rows that are exact duplicates, the test accounts (IDs that start with TEST), and the number of different ways the branch name is written.
str.startswith("TEST") tells you whether a string starts with "TEST".
This step's code cell is for members.Sign up free
Remove the duplicate rows and the test accounts. Then make the branch names match the spelling in branches.csv: strip the spaces, lowercase the text, and map it with the names dictionary. Some spellings differ in more than case and spaces (Oldtown, Mid Town, Harbourside, Westend), which is why the dictionary is needed. Six branch names should remain. A spelling that cannot be matched shows up as NaN.
This step's code cell is for members.Sign up free
Code cells are for members
You can read the steps. Sign up free to run the code, complete the steps and save your progress.
Most sign-up dates look like 2025-03-14, but some are written 14.03.2025. Try the ISO format first and fill the values that could not be converted with the second format. The cancel dates all use one format; the empty ones stay NaT (active member).
The fee column has three shapes: $70, 70,00, and 70. Remove the $ sign and the ,00 ending, then convert the result to a number. We will not fill the empty ages; just note how many there are.
This step's code cell is for members.Sign up free
Add the flex_plan column from the branch table to the members. After the merge, check that the number of rows did not change and that no member is unmatched. Save the result in a new full table; do not change members.
For a difference-in-differences comparison to be fair, the members of the pilot branches should look like the others. Compare the number of members, the median age, the average monthly visits, and the share of annual plans for each branch, and the averages of the two groups.
This step's code cell is for members.Sign up free
The main metric is the monthly churn rate: members who left in a month / active members at the start of the month. To get the rate for each group, divide the group's total churned members by its total active members instead of averaging the branch rates, so larger branches get the weight they deserve.
Plot the monthly rate of the two groups on one chart and mark the start of the plan, January 1, 2026, with a dashed line.
This step's code cell is for members.Sign up free
The first idea that comes to mind is to compare the six months before the plan in the pilot branches (July to December 2025) with the six months after (January to June 2026). Do the same calculation for the other branches.
Why might the rate change in the other branches, where nothing changed? Look at February and March on the chart: some of the people who sign up in January because of a new year's resolution quit within a few months.
This step's code cell is for members.Sign up free
The other branches are the control group: they show what would have happened in the pilot branches without the plan. The effect of the plan is the change in the pilot branches minus the change in the control branches.
The method assumes that the two groups moved in parallel before the plan. To check this, look at the monthly gap between the two groups from July to December 2025. The monthly rates are noisy, because each branch loses only about 5 to 25 members a month. What you look for is a trend: the gap should not keep opening or closing in one direction.
This step's code cell is for members.Sign up free
You can make the same estimate with a regression, which also gives you a confidence interval and a p-value. Each branch-month is one observation. The effect column is 1 only for the pilot branches in the months after the plan. C(branch_id) controls for permanent differences between branches, and C(month) controls for the seasonal effect that touches all branches together; the remaining effect coefficient is the difference-in-differences estimate.
Limitation: the months of the same branch resemble each other, and this model's standard error does not account for that, so the p-value is slightly optimistic.
This step's code cell is for members.Sign up free
Go back to the member list. Split the members into four groups by their average monthly visits and calculate the churn rate of each group; do the same for the plan type. Test the relationship between visit group and churn with a chi-square test and measure its strength with Cramér's V (for a table with two columns, V = sqrt(chi² / n)).
Note: members signed up at different times, so the churn rates cover periods of different lengths. This table describes the data; it does not show causes.
This step's code cell is for members.Sign up free
Write the summary for the board, using numbers. If the plan is rolled out to the other three branches, how many lost members per month would it prevent? Estimate it by multiplying the average monthly number of active members in the control branches in 2026 by the difference-in-differences estimate; then turn the prevented loss into revenue using the average fee of active members.
The summary should contain the result, the uncertainty, the recommendation, and the limitation.
This step's code cell is for members.Sign up free