Capstone · lesson 4 of 10
Parts in this lesson
Adf.groupby("region")["price"].describe()9.1: a summary per group
Bsns.relplot(data=df, x="month", y="price", col="region", kind="line", col_wrap=4)7.6: small multiples, one panel per place

Exploring it

Last updated

Before answering your question, look at the clean data from every side, in the same order as 9.1: shape, types, one variable at a time, then two, then many. In this lesson you'll run that workflow on your capstone data, chart every variable, and keep a list of surprises, checking each one before it's allowed to shape the answer.

By the end of this lesson you can

  • Run the EDA workflow on a new, real dataset
  • Chart every variable over time and by place
  • Keep a list of surprises, and check each one at the source

The workflow

Start 04-explore.ipynb, reading data/clean/rice.csv (or your own clean file). Work through the checklist from 9.1, ticking as you go:

EDA checklist, capstone0 of 6

Write a sentence of what you saw under every output. A chart with nothing written under it hasn’t been looked at yet.

A starting point for the rice data:

import pandas as pd
import seaborn as sns

df = pd.read_csv("data/clean/rice.csv", parse_dates=["month"])
print(df.shape)
df.info()

# missing values, by region and by year
df.assign(year=df["month"].dt.year).pivot_table(
    index="region", columns="year", values="price", aggfunc=lambda s: s.isna().sum())

# one variable at a time
df.groupby(["rice", "region"])["price"].describe().round(1)

# every place over time, on one shared scale
g = sns.relplot(data=df, x="month", y="price", hue="rice", col="region",
                kind="line", col_wrap=4, height=2, aspect=1.4)
g.set_titles("{col_name}")

The missing-values table by place and year is worth its space: a gap in one region for one year is a story (a lockdown, a typhoon, a change of survey), and it changes what can be compared.

Every variable, every place

Small multiples (7.6): one small panel per region, all on the same scale, so the eye can compare shapes. Look for:

  • The common pattern: do all regions move together? A shared rise is national (world prices, policy); a rise in one region is local (a typhoon, transport costs).
  • The odd one out: the region whose line looks different from the rest.
  • Breaks: a sudden step in every region in the same month is usually a change in how the data was collected, not a change in prices.
  • The spread: which regions are always dearest, and is the gap growing or shrinking?

For the rain question, the same applies to months and years at your station: a panel per month, or per decade. For schools, a panel per region, with one line per level.

Surprises

Keep a numbered list of surprises in the notebook. For each, check it against the source before believing or using it: the publisher's notes, the original release, or a second source.

## Surprises (examples of the form: yours come from your data)

1. One region has no prices for six months in a row.
   Checked: (what the publisher’s notes say about it). Decision: keep as missing.
2. One region’s price drops by ₱10 in one month, then returns.
   Checked: the monthly release for that month shows the same figure.
   Real, or an error at the source? Unknown: flag it, and test whether the answer depends on it (C.5).
3. A kind of rice disappears from every region from one month on.
   Checked: (what the notes say). Decision: compare only the months both kinds were collected.

Some surprises are the finding. Most are an artefact of the data: a gap, a revision, a change of definition. You can't tell which until you check, and the report (C.7) has to say which they were.

The reference analysis of the rain question had a big one. Counting the days with a value in each year, the station is complete every day from 1961 to 2000, and from 2001 has only about half. The source flag on each value showed why: in 2001 NOAA's source for the station changes, from its international collection to daily summaries made from weather messages. So a chart of yearly totals would have shown a sudden drop in 2001, caused by a change in the record, not the weather. The reference uses the station only to 2000, and CHIRPS for the years since. Its cleaning log:

station file: 23113 days, 01 March 1945 to 24 August 2025
dropped 3607 days with no rainfall value (the file holds temperatures too)
  dropped 14 March 2009: 360.2 mm failed a quality check (flag O)
  source flag I: 1961 to 2000
  source flag S: 2001 to 2025
23 years have fewer than 95% of their days: 2001 to 2025 (on average 197 days a year)
kept the longest run of complete years, 1961 to 2000; left out complete years outside it: 2004
wrote data/clean/rain_daily.csv: 14610 days
CHIRPS: 1653 dekads, 01 January 1981 to 21 November 2026; dropped 3 preliminary ones (November 2026 on)
added the dekads up into 550 months; dropped 0 without all three dekads
dropped 10 months of 2026, not a whole year yet
wrote data/clean/rain_monthly.csv: 540 months (1981 to 2025), 240 with the station's total beside CHIRPS

Check what you learned

Every region’s price jumps by the same amount in the same month, then stays there. What do you check first?
Why put every region on the same y scale in small multiples?

Sources

Every example on this page was run with Python 3.14, and its output and error messages are copied from it. These pages cover the same ground in more depth.

All sources for Simple Data Analysis