Before this: Map categories with an approved dictionary
The idea
A mapping table has the raw (normalized) value, the approved value, and who approved it when. It can be reviewed like any other data.
Join or look up against it in SQL and pandas, and use the same pairs in the visual Map values step, so all tracks agree.
Changing a mapping is then a reviewed data change, not a code edit.
Worked example
Input: raw: e-mail → email; web chat → chat
- Visual
Add step → Map values → paste the approved pairs
- SQL (DuckDB)
LEFT JOIN channel_map m ON m.raw = lower(trim(t.channel))
- pandas
df["channel"].str.strip().str.lower().map(dict(zip(cm.raw, cm.approved)))
Result: Every tool maps the same way
Common mistakes
- Mappings buried in code.
- Different mappings per tool.
- Keys not normalized like the data.
Check yourself
Why keep who approved each mapping?
So changes can be audited and questioned.
Practice it
Map channels with an approved dictionary.