Data Cleaning Exercises

Module 12

Joins

Referential integrity, null keys, cardinality checks, orphan rows and duplicated totals.
  1. Joins where missing keys never match

    Look up values without letting a missing key match another missing key, in every tool. · 10 min

  2. Report orphans, don't drop them

    Join facts to a master table without losing rows, and report unmatched keys with a reason. · 8 min

  3. State the cardinality before you join

    Declare whether a join is one-to-one or many-to-one and make violations fail loudly. · 8 min

  4. Null keys in pandas merges

    Prevent pandas from matching missing keys to each other. · 6 min

Module 12 quiz

Practice questions: choose an answer and check it to see the explanation. Nothing here is timed or graded.

  1. 1. Orders (1,000 rows) LEFT JOIN customers on customer_key, where 10 keys appear twice in customers. How many rows can the result have?
  2. 2. Some payments reference accounts missing from the master. What should the clean output do?
  3. 3. pandas merge(..., validate="many_to_one") does what?
  4. 4. Why compare row counts and totals before and after a join?
  5. 5. pandas merge on a key column where both sides have NaN keys: do NaN keys match?
  6. 6. A lookup table has the same key twice with different values. What should you do?