Data Cleaning Exercises

Module 5 · Categories and mappings · 6 min

Reviewing a mapping change

You'll be able to: Change a category mapping safely and measure its effect before releasing it.

Before this: Map categories with an approved dictionary

The idea

Adding 'web-chat → chat' moves rows from exceptions to a category. Before releasing, count how many rows change and check examples.

Version the mapping table and note who approved the change, so reports can be explained later.

Worked example

Input: new pair: web-chat → chat

Visual
Map values → add pair → compare before/after counts
SQL (DuckDB)
SELECT approved, COUNT(*) FROM mapped GROUP BY ALL
pandas
df_new["channel"].value_counts() - df_old["channel"].value_counts()

Result: chat +14 rows, unmapped −14

Common mistakes

  • Unreviewed mapping edits.
  • No record of who approved a change.

Check yourself

What should you measure before releasing a mapping change?

How many rows move and to which categories.

Practice it

Map channels with an approved dictionary.

Next: Map channels with an approved dictionary