pandas: Anti-Joins and Mismatched Keys

medium
Unit 9 · Pandas II0/3 to milestone

Reconciling two systems (orders vs payments, CRM vs billing) means finding rows that don't match. Implement with pandas:

  • anti_join(left, right, on): rows of left whose on key does not appear in right, with the original columns and order and a fresh index.
  • reconcile(orders, payments): both DataFrames have columns order_id and amount. Return a dict:
    • "missing_payment": sorted list of order ids with no payment
    • "orphan_payment": sorted list of payment order ids with no order
    • "amount_mismatch": sorted list of ids present in both where the amounts differ by more than 0.01 (sum payments per order first, since an order can be paid in several parts)
#pandas#joins#data-quality2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
pandas: Anti-Joins and Mismatched Keys · TechGradify