Sub topic 15
Summarizing the Analysis for the Next Reader
This chapter covers the last step of an exploratory data analysis (EDA): writing the summary that lets someone else use your work without rerunning it. It assumes you can use pandas and Jupyter. It also assumes you have followed the earlier chapters: you have a notebook with a setup cell, a cleaning function, labeled plots, and a findings log. You may also have moved stable code into a module.
Why the handoff needs its own step
By the end of an EDA, the notebook holds a lot: loading code, audits, cleaning rules, dozens of plots, and a findings log written as you went. The next reader is a teammate, a stakeholder, or you in three months. That reader usually wants answers to four questions:
- What was the question, and what is the short answer?
- Can I trust the data behind it?
- What did you decide along the way, and what did those decisions cost?
- What should happen next?
If the reader must scroll through every cell to find these answers, the notebook has failed at its last job. The findings log is a working record in the order you discovered things. The handoff summary is a different document. It is organized by what the reader needs, not by when you learned it.
Where the summary lives
Put the summary at the top of the notebook, directly under the title. Readers rarely scroll to the bottom. The summary also stays next to the code and evidence it describes, so it is less likely to go stale than a separate document.
For a wider audience, you can also export a short standalone version, such as a README.md or a one-page report. The notebook's top cell stays the source of truth.
A common layout:
| Section | Purpose |
|---|---|
| Title and date | Name the analysis and say when it was run |
| Question and scope | State what you set out to learn |
| Key findings | Give the three to five most important results |
| Data and cleaning | Describe the source, the row counts, and the rules applied |
| Caveats | List what could make the findings wrong |
| Open questions and next steps | Say what remains unknown or untested |
| How to reproduce | Give the exact steps to rerun |
Writing the key findings
Select findings from the log. Do not copy the whole log. Keep a finding if it answers the original question or changes what someone would do. Drop dead ends from the summary, though they can stay in the notebook body.
Each finding should state the result with a number, name the evidence, and say how confident you are. Compare these two versions:
- Weak: "Amounts are skewed and the regions differ."
- Strong: "Order amounts are right-skewed (median 48, mean 71), so the mean overstates a typical order. The West region has the highest median (62 versus 45 to 50 elsewhere). See the grouped box plot in section 5."
The strong version gives figures, points to a place in the notebook, and states a claim narrow enough to check.
Separate observations from interpretations. "The median is lower than the mean" is an observation. "A few large orders drive the mean" is a hypothesis until you test it. Label each one so the reader knows which is which.
Keep the numbers in sync with the code
A summary typed by hand can drift from the data. You change a cleaning rule, rerun the notebook, and the text still quotes the old row count. Two habits reduce this risk.
First, compute the numbers you quote and print them in one place. Second, build the summary text from those values so it updates when the data changes.
import pandas as pd
df_raw = pd.DataFrame({
"order_id": [1, 2, 2, 3, 4, 5],
"region": [" West", "east", "east", "West ", "north", "east"],
"amount": [120.0, 45.0, 45.0, None, -5.0, 50.0],
})
def clean_orders(df):
out = df.drop_duplicates().copy()
out["region"] = out["region"].str.strip().str.lower()
out = out[out["amount"].notna() & (out["amount"] >= 0)]
return out
df = clean_orders(df_raw)
summary = {
"rows_raw": len(df_raw),
"rows_clean": len(df),
"rows_dropped": len(df_raw) - len(df),
"median_amount": df["amount"].median(),
"mean_amount": df["amount"].mean(),
"top_region": df.groupby("region")["amount"].median().idxmax(),
}
print(
f"Kept {summary['rows_clean']} of {summary['rows_raw']} rows "
f"({summary['rows_dropped']} dropped by cleaning).\n"
f"Median order amount: {summary['median_amount']:.1f}; "
f"mean: {summary['mean_amount']:.1f}.\n"
f"Region with the highest median: {summary['top_region']}."
)This example uses a tiny made-up table so that it runs on its own. In your notebook, df_raw comes from your loading cell. Running it prints:
Kept 3 of 6 rows (3 dropped by cleaning).
Median order amount: 50.0; mean: 71.7.
Region with the highest median: west.You can paste these printed lines into the summary cell, or use IPython's Markdown display class to render text built from variables. Either way, the numbers come from the same run as the evidence.
Documenting the data and cleaning decisions
The reader needs to know what you removed and why. For each rule in your cleaning function, record three things: what it does, how many rows it affects, and the reason. A table works well:
| Rule | Rows affected | Reason |
|---|---|---|
| Drop exact duplicate rows | 1 | Repeated export lines |
| Drop rows with missing amount | 1 | Cannot be analyzed without a value |
| Drop rows with negative amount | 1 | Likely refunds, outside the question's scope |
The last "Reason" is a guess about refunds. Say so. If you are unsure why values are negative, write "unknown, to confirm with the data owner." An honest gap is more useful than a confident invention.
Also record the data's provenance: the file path or query, the extraction date, and the date range the data covers. A summary that says "orders data" without a time range invites wrong conclusions later.
Caveats and limits
A caveat names a specific way the findings could be wrong. Vague warnings such as "more analysis is needed" are not caveats. Useful ones include:
- Rows dropped for missing values may differ systematically from kept rows. If missing amounts cluster in one region, regional comparisons are biased.
- A correlation was found by checking many pairs of variables. Some of those patterns can appear by chance, as the pitfalls chapter explained.
- The data covers one quarter, so seasonal effects are not visible.
- Any rule in the cleaning function that you chose by looking at the full dataset may leak information into later modeling.
Write caveats in order of how much they could change the conclusion.
Open questions and next steps
List questions the analysis raised but did not answer. For each one, say what data or test would answer it. For example: "Do large orders cluster in the West region? Test by comparing the share of orders above the 95th percentile per region." Questions stated this way become tasks someone can pick up.
Making the handoff reproducible
The last check before handing off is the one from the hygiene chapter: restart the kernel and run all cells in order. A summary is only credible if the notebook behind it runs from top to bottom without errors. Do this after you finish editing the summary, because edits to earlier cells can change the numbers.
Then record the environment. Note the Python version and the versions of key libraries, and state where the raw data lives. If you moved code into a module, name it in the reproduction section.
import platform
import sys
import matplotlib
import numpy as np
import pandas as pd
print("python:", sys.version.split()[0], "on", platform.system())
for lib in (pd, np, matplotlib):
print(f"{lib.__name__}: {lib.__version__}")For a longer-lived project, also save a dependency file such as requirements.txt, and consider saving an HTML or PDF export of the notebook after the final run. An export is a fixed snapshot. The reader can see outputs without installing anything.
A skeleton for the summary cell
The following Markdown cell can sit at the top of the notebook. Replace the bracketed placeholders with your own values.
# Order amount analysis
**Date run:** [YYYY-MM-DD] | **Data:** `data/raw/orders.csv`, [start date] to [end date]
## Question
Which factors explain differences in order amount?
## Key findings
1. Order amounts are right-skewed (median [X], mean [Y]). Use the median as the typical value. See section 5.
2. [Region] has the highest median amount. Hypothesis: [reason]. Not yet tested.
## Data and cleaning
Kept [N] of [M] rows. Rules: drop duplicates, drop missing or negative amounts. See section 3.
## Caveats
- [Most important caveat]
## Next steps
- [Question] to be answered by [test or data].
## Reproduce
Python [version]. Restart the kernel and run all cells from the top.The flow from log to summary
Common errors
- Summary written first, never updated. The text describes an earlier version of the analysis. Write or finalize it last, and generate numbers from code.
- Findings without evidence. A claim with no pointer to a plot or table cannot be checked. Name the section.
- Hiding the dropped rows. Readers assume the data is complete. State the row counts before and after cleaning.
- Burying the answer. Put the conclusion first and the method after it.
- Overstating certainty. Words like "proves" and "causes" are rarely justified by EDA. Use "suggests" and "is consistent with" and say what test would confirm.
- Skipping the audience. A technical teammate wants cleaning rules. A stakeholder wants the answer and the decision it supports. Write for the main reader, and link to detail for the other.
Checking your own summary
Before sharing, give the top cell to someone who has not seen the notebook, or reread it as if you had not. Check that the question is stated, that every finding has a number and a location, that the row counts are present, and that at least one caveat could change the conclusion. If you cannot answer "what should I do next?" from the summary alone, add it.
Exercise
Your summary says "We removed some bad rows." Rewrite it so a reader can judge the effect of cleaning. Name three pieces of information to add.
Show answer
Add (1) the row counts before and after cleaning, for example "kept 9,540 of 10,000 rows"; (2) each rule that removed rows, with the number of rows it affected; and (3) the reason for each rule, marking any reason that is a guess. Printing the counts from code keeps them correct if the rules change.
Exercise
You finish the summary, then fix a typo in the cleaning function and save the notebook without rerunning it. What is the risk, and what should you do?
Show answer
The saved outputs, and any numbers in the summary, may no longer match the code. If the fix changed behavior, the quoted row counts and statistics are stale. Restart the kernel, run all cells in order, check that the summary numbers still match, and then save and share.
Exercise
A finding reads "Region West drives higher amounts." List what is wrong with it as a handoff statement and rewrite it.
Show answer
It has no number, no evidence location, and implies causation, which EDA cannot establish. A better version: "West has the highest median order amount (62 versus 45 to 50 in other regions; grouped box plot, section 5). This is an observation. Whether region causes the difference is untested, and a next step is to check product mix by region."