Skip to content
ProtocolProtocol
← Your pathLevel 1 · Beginner

Joins that lose rows, and how to prove they did not

Lesson 3 of 6 · Spreadsheets and instrument exports

1 · Learn the move · Fact-check list

Every bench dataset is really two tables - the measurements and the sample sheet - and the join between them is where rows go to die quietly. Keys fail for dull reasons: a trailing space, S1 versus S01, a well written B3 in one file and B03 in the other, an ID Excel turned into a date. An inner join drops every casualty without a word, and the analysis runs fine on the survivors. The discipline is a fact-check list of counts, stated every single time: rows in the left table, rows in the right, rows matched, unmatched-left with examples, unmatched-right with examples. The area's done-check is exactly this - counts stated and matched before and after every join. If unmatched is not zero, the next step is diagnosing the key mismatch, not proceeding; and the model can draft the diagnosis, but whether 3 lost rows is a bug or 3 genuinely absent samples is your call, made looking at the actual IDs.

Join [measurements table] to [sample sheet] on [key]. Before joining, report: rows and distinct keys in each table, and any duplicate keys. After joining, report the reconciliation: matched rows, unmatched-left (count + up to 10 example keys), unmatched-right (same). If either unmatched count is nonzero, stop and diagnose: compare unmatched keys across tables for whitespace, case, zero-padding, and format differences, and show likely pairs. Do not proceed to analysis on a join with unexplained losses.

2 · Your turn. You write the prompt

Your 96 measured wells joined to your sample sheet and came back as 91 rows, and the analysis notebook happily ran on the 91. Five samples are simply not in the results, and nothing anywhere said so. Write the prompt where the join proves itself with counts before anything downstream is allowed to run.

Remember: the AI sees only your prompt, not this page. If the situation isn't in your prompt, it doesn't exist.

Optional. These shape the output when you run your prompt below, not your score.