Check a column's range and missing values¶
Draft: not yet validated
The code on this page was run inside MESA JupyterLab on 2026-11-13 and produced the output shown. Nobody has yet followed the steps there by hand, so a menu or a screen may differ. Tell us what you find.
You will: know the range of value at each gauge and how many blanks each column
of readings holds.
Time: 5 minutes. You need: the notebook from
Load a file from your Data Store into a notebook, open in
MESA JupyterLab, with its first cell run so that readings
and gauges exist.
Steps¶
-
Run:
readings["value"].min(), readings["value"].max()You should see:
0.0and180.0. Depending on the pandas version, each number may be wrapped asnp.float64(...). -
Ask whether both ends are believable. Zero is a dry day. Decide whether 180 could be one day's rain before you read on.
You should see: a reason to look closer. A range tells you that something is unusual, not what it is.
-
Split the range by gauge:
readings.groupby("gauge_id")["value"].agg(["min", "max"])You should see:
min max gauge_id G01 0.0 24.90 G02 0.0 2.92 G03 0.0 32.50 G04 0.0 26.40 G05 0.0 180.00 -
Count the blanks in every column:
readings.isna().sum()You should see:
gauge_id 0 date 0 value 0 flag 150 dtype: int64 -
Check the blanks against the data dictionary.
You should see: that a blank
flagis expected, since it means the sensor raised no concern, and thatvalueis never blank.
Check it worked¶
You can state two things: the largest value at each gauge, and that the only column
with blanks is flag, with 150 of them.
If it didn't¶
The counts in step 4 are all zero. flag was read as empty text, not as missing.
That happens when the file is loaded with keep_default_na=False. Load it again with
plain pd.read_csv("readings.csv").
Next¶
- Tally a quality flag before you trust a number, which follows up the 180.
- "No blank values" does not mean "no missing days": a day with no row at all is not a blank. Count records per day to find incomplete days covers that.
- Reference: Working with missing data in the pandas user guide.
Not yet validated by a person in MESA JupyterLab. Drafted with AI assistance on 2026-11-12; the code was run there on 2026-11-13 (pandas 3.1.1, DuckDB 2.0.0).
Machine-readable versions of this page: Markdown twin · raw source on GitHub · llms.txt · llms-full.txt (whole site). See For AI agents.