Combining Tables and Checking Unmatched Records
Unit ID: M09-U07 Estimated active time: 30-45 minutes
Use a checked merge when one table supplies labels for keys in another.
joined = clean.merge(modules, on="module_id", how="left", validate="many_to_one", indicator=True)
unmatched = joined.loc[joined["_merge"] != "both", "module_id"].drop_duplicates()
validate="many_to_one" states the expected relationship. The indicator exposes unmatched keys. Never assume a merge kept the intended rows; compare counts and inspect unmatched records.
Practice: explain why an inner join would hide an unknown module and why a left join plus an unmatched report is better evidence here.
