Normalise the key before joining
Trailing spaces, mixed case, and leading zeros make keys that look identical and are not. Strip, casefold, and pad on both sides before the join, and the misses drop to the real ones.
Real analysis needs more than one file, and joining them is where rows get lost or duplicated. A join is a dictionary lookup on a key, and the failure modes are the same in every language: keys that do not match, and keys that match more than once.
About 2 min of reading
Join two lists and report the match rate.
Build both sides
Before you run it, say out loud what it will print. Then open the answer.
Join and count misses
Before you run it, say out loud what it will print. Then open the answer.
Before you write anything, put these lines back in the right order. Click a line to move it up one step. This support step is easier than writing code from scratch, and it is here to make the last example stick.
Read the first example one line at a time. A line that prints shows what appears on screen; the rest set things up quietly.
Trailing spaces, mixed case, and leading zeros make keys that look identical and are not. Strip, casefold, and pad on both sides before the join, and the misses drop to the real ones.
A left join keeps the base rows and loses data; a right join answers a different question. Say which side is the population you are making claims about, and the other side is just attributes.
index = {r['id']: r for r in other} then for each row attach index.get(row['id']). This is a left join, and .get() makes the misses visible instead of crashing.
If the index has two rows with the same key, the dictionary keeps the last one and you lose the first without a word. Count the keys before you index: len(index) must equal len(other) or the key is not unique.
'joined 1,204 of 1,310 rows' is the number you must publish. A 92 percent match rate changes what the answer means, and a 100 percent rate is often the sign that the wrong key was used.
Each one is defined here on this site. Open the entry for the full definition and the other words it points at.