Skip to content

Compare two files that should look alike

Draft: not yet validated

The code on this page was run inside MESA JupyterLab on 2026-11-17, by the AI assistant that drafted it, and produced the output shown. No person has yet followed the steps, so a menu or a screen may differ. Tell us what you find.

A second file of the same kind is a free expectation. Two months from the same five gauges should have the same columns, about the same number of rows, and values of a similar size. Where they differ is where to look.

You will: have a short list of the places where July's readings and August's differ, each one a question to follow up.

Time: 10 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, and readings_august.csv from the practice data in the same folder.

Steps

  1. Load August and compare the row counts. Five gauges over 31 days would give 155 rows in each month.

    august = pd.read_csv("readings_august.csv")
    len(readings), len(august)
    

    You should see: (152, 151). Neither month is complete.

  2. Check that the columns match:

    list(readings.columns) == list(august.columns)
    

    You should see: True.

  3. Count the rows for each gauge, with the months side by side:

    pd.DataFrame({
        "july": readings.groupby("gauge_id")["value"].count(),
        "august": august.groupby("gauge_id")["value"].count(),
    })
    

    You should see: 31 nearly everywhere. July is short at G01 and one over at G03. August is short at G03.

              july  august
    gauge_id
    G01         27      31
    G02         31      31
    G03         32      27
    G04         31      31
    G05         31      31
    
  4. Do the same for the largest reading:

    pd.DataFrame({
        "july": readings.groupby("gauge_id")["value"].max(),
        "august": august.groupby("gauge_id")["value"].max(),
    })
    

    You should see: four gauges within 0.2 of their other month, and G05 with 180 in July against 27.4 in August.

                july  august
    gauge_id
    G01        24.90   24.80
    G02         2.92    2.84
    G03        32.50   32.30
    G04        26.40   26.30
    G05       180.00   27.40
    
  5. Compare the flags. July has two readings flagged S. For August:

    august["flag"].value_counts(dropna=False)
    

    You should see: no flag on any row.

    flag
    NaN    151
    Name: count, dtype: int64
    
  6. In a Markdown cell, list each difference as a question.

    You should see: a list such as "July G01: four days missing? July G03: a repeated row? July G05: is 180 real? August G03: four days missing?"

Check it worked

Your list has four entries, each naming a month and a gauge. None of them is answered yet: the comparison tells you where to look, not what happened.

If it didn't

Step 1 says the file is not found. readings_august.csv is not in the folder the notebook is in. Run the download cell on the practice data page.

A table shows NaN for a gauge. That gauge has no rows in one of the files. That is a difference too; add it to your list.

Next

Not yet validated by a person in MESA JupyterLab. Drafted with AI assistance on 2026-11-17; the code was run there that day (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.