Sub topic 15
Writing down findings and next questions
This chapter assumes you have worked through the earlier chapters. You can load the Titanic CSV, check missing values, filter rows, build an AgeGroup column, use groupby, and read a correlation table. The last step of an exploration is to record what you learned, so the work can be checked and repeated later.
Why write findings down
Exploration produces many printed tables. A week later you will not remember which ones mattered. A short written record keeps the results, the caveats, and the open questions together. It also lets someone else see what you checked and what you left unchecked.
A good record separates three things:
- Observations: what the data shows, with numbers.
- Caveats: what limits how far you can trust an observation.
- Next questions: what you would check or ask next.
A structure for findings
Write each finding as a claim, the evidence, and a caveat. Keep it to a few lines.
| Claim | Evidence | Caveat |
|---|---|---|
| Women survived at a much higher rate than men | `groupby("Sex")` mean of `Survived` | Sex is tied to class and age, so it may not act alone |
| Survival falls from first to third class | `groupby("Pclass")` mean of `Survived` | Class and fare move together |
| Age is missing for part of the rows | `df.isna().sum()` | Age-based results use only passengers with a known age |
| `Cabin` is mostly missing | missing-value table | Too sparse to use without more work |
Quote numbers from your own output, not from memory. Where a rate rests on a small group, give the count next to it.
Keep the numbers in code
You can make the record repeatable by computing the key figures in one place. This script rebuilds a small summary table from the raw CSV.
import pandas as pd
df = pd.read_csv("train.csv")
summary = {
"rows": len(df),
"overall_survival_rate": round(df["Survived"].mean(), 3),
"age_missing_pct": round(df["Age"].isna().mean() * 100, 1),
"cabin_missing_pct": round(df["Cabin"].isna().mean() * 100, 1),
"duplicate_rows": int(df.duplicated().sum()),
}
by_sex = df.groupby("Sex")["Survived"].agg(["count", "mean"]).round(3)
print(pd.Series(summary))
print(by_sex)Rerun this after any change to the data or the cleaning steps. If a number changes, your notes are out of date. Paste the output into your notes, or save it with summary_table.to_csv(...) if you want a file.
Turning caveats into questions
Each caveat points to a next step. A good question is specific enough that you know what code would answer it.
- Does the sex gap in survival remain within each class? Check with
groupby(["Pclass", "Sex"]). - Are passengers with a missing
Agedifferent from the rest? Compare their survival rate and class with the others. - Which groups are too small to compare? List counts for every group you reported.
- Are the values plausible? Look for ages or fares that make no sense.
A short template
Keep a notes file next to the notebook, with the same headings every time.
## Data
Source, file name, rows, columns, date checked.
## Findings
1. Claim. Evidence. Caveat.
## Data problems
Missing values, duplicates, odd values, and what you did about each.
## Next questions
1. Question. The code or data needed to answer it.Exercise
You find that first-class passengers survived at a higher rate than third-class passengers. Write one finding in the form claim, evidence, caveat, and one next question.
Show answer
Claim: first-class passengers survived at a higher rate than third-class passengers. Evidence: df.groupby("Pclass")["Survived"].agg(["count", "mean"]) shows the survival rate and group size for each class. Caveat: class is related to sex, age, and fare, so class may not be the only factor. Next question: does the gap remain when you compare men with men and women with women, using groupby(["Pclass", "Sex"])?