Before this: Trim the right characters, and only those
The idea
Lowercasing makes 'Shipped' and 'shipped' equal, which is right for status codes and emails under most policies, but wrong for names, product codes or case-sensitive ids.
Apply case changes to the columns the rules name. For matching other text, build a comparison key and keep the original value.
Record the policy so others know why values changed.
Worked example
Input: status: 'Shipped', 'shipped'; name: 'McDonald'
- Visual
Add step → Change case → status → lowercase (name untouched)
- SQL (DuckDB)
lower(status) AS status
- pandas
df["status"] = df["status"].str.lower()
Result: status: shipped, shipped; name stays McDonald
Common mistakes
- Lowercasing everything.
- Losing the original value.
- Undocumented case rules.
Check yourself
Should product codes be lowercased to match?
Only if the rules say codes are case-insensitive; otherwise compare exactly.
Practice it
Normalize emails under a declared policy.