Clean and standardize: the silver layer
Stage 3 begins: transform. Bronze is faithful but messy — temperatures arrive as nested JSON objects, timestamps as strings, coordinates as GeoJSON arrays. Silver is where observations become a real table: flat columns, real types, a geometry column with a declared CRS. This is the dataset every later stage trusts.
The code
import geopandas as gpd
import pandas as pd
raw = gpd.read_file("lake/bronze/nws/date=2026-11-12/observations.json")
silver = pd.DataFrame({
"station": raw["station"].str.rsplit("/", n=1).str[-1],
"time": pd.to_datetime(raw["timestamp"]),
"temp_c": raw["temperature"].apply(lambda t: t["value"]),
"geometry": gpd.points_from_xy(raw.geometry.x, raw.geometry.y),
}).pipe(gpd.GeoDataFrame, crs="EPSG:4326")
silver = silver.dropna(subset=["temp_c"])
silver.to_parquet("lake/silver/observations/date=2026-11-12.parquet")
In practice
Three standardizations do the work. Types: strings become datetimes and floats, so sorting and math behave. Shape: nested objects flatten into columns — temperature.value becomes temp_c. Space: bare coordinates become a geometry column with a CRS attached.
Declare, don't transform. The API speaks WGS84 longitude/latitude, so we *set* the CRS to EPSG:4326 — telling GeoPandas what the numbers mean. to_crs() would be for *changing* that meaning (say, to metres for distance work). Mixing the two up is the classic silent-corruption bug: the numbers stay the same while their meaning shifts.
Drop in silver, never in bronze. A temperature row with no temperature is noise for this pipeline, so dropna removes it — from silver. The raw row still exists in bronze if another consumer ever wants it. And the output goes to Parquet (Lesson 14), partitioned by date like everything else in the lake.
Python bridge: Every line here is pandas and GeoPandas you already know. Silver is just 'the cleaning script you would write anyway', given a name, a fixed input (bronze), and an output contract.
Further reading
Projections — GeoPandas user guide (the GeoPandas guide to setting a CRS vs re-projecting with to_crs — the distinction this lesson leans on)
Try it
Practice question: A row arrives with temp_c = 999.9 (a classic sensor error code), and another with latitude 140.2. Which of these does today's silver code catch, which slip through — and what is the one-line fix for the ones that slip?
Show answer
silver = silver[
silver.geometry.y.between(-90, 90)
& silver["temp_c"].between(-60, 60)
]
Result: Neither is caught: dropna only removes missing values, and 999.9 and 140.2 are present, just impossible — latitude cannot exceed 90, and 999.9 °C is a sensor error code, not weather. Range filters (above) remove both. The lesson inside the lesson: type-clean is not value-clean — which is why tomorrow's lesson adds explicit quality checks instead of hoping the cleaning code catches everything.