promptdojo_

Mission: API rows to a model-ready DataFrame — step 1 of 7

Mission: API to DataFrame

Every model in this arc eats a table, and something has to make that table. Build the smallest converter that produces one, feed it a batch of genuinely messy records, then reinforce wherever it bent.

The job: take API-shaped records (chapter 02's nested JSON) and turn them into a clean, typed table you could hand to pandas — the same pipeline you'd run before any analysis or model.

The stages:

  1. Flatten — pull the fields you need out of nested dicts, one flat record per row (the bracket-walking from chapter 02).
  2. Type — cast at the boundary: amounts to float, dates parsed, junk to an explicit "missing" marker. This is chapter 03's try/except cast plus this chapter's dtype lesson.
  3. Validate — count what you kept, what you dropped, and why. A pipeline that can't report its drop rate is hiding bugs.
  4. Summarize — one groupby-style aggregate per entity to prove the table is usable.

Run the editor: the starter does stages 2 and 3 on three messy rows. Your mission extends it — more fields, a real drop report, and a per-user summary. On your own machine, the final clean list is one pd.DataFrame(clean) away from everything pandas offers.

The skill here isn't a library call — it's owning the seam where mess becomes data: messy records in, typed table + drop report out, with the try/except cast standing guard so the next batch can't sneak junk past you.