Research Workflow
Detect Category Drift Across Data Releases
Define the allowed vocabulary
A categorical field can change without its column name changing. An export might replace Yes with Y, add Unknown, or merge two response options. Begin with the approved levels and their meanings, including missingness and structural not-applicable categories. Preserve ordering only when it has a substantive interpretation.
The pandas categorical-data guide distinguishes category definitions from observed values and explains explicit categorical types. This is useful for enforcing a vocabulary, but enforcement should not quietly convert unexpected labels into missing data without a report.
Compare releases before stacking them
For each release, list raw distinct labels and counts, declared levels and any ordering. Compare both label spelling and meaning. A stable label can conceal a changed definition, while a harmless spelling change can create a new level in software.
Keep a versioned recoding map with source label, target label, effective date and rationale. Investigate unexpected values before assigning them to Other. That category can become a hiding place for import errors, newly valid responses and genuinely heterogeneous observations.
Reconcile a hypothetical release
Suppose release one contains Yes 60 and No 40. Release two contains Y 55, N 35 and Unknown 10. A confirmed mapping can convert Y to Yes and N to No, but Unknown is not automatically No. Across both releases the reconciled counts are Yes 115, No 75 and Unknown 10, totaling 200.
If Unknown is silently converted to missing and dropped, a percentage computed among known responses becomes 115/190 = 60.53%. A percentage over all records is 115/200 = 57.5%. Neither denominator should appear without explanation. The changed vocabulary has created an analysis decision as well as a cleaning task.
Test downstream consequences
Check model reference categories, plot ordering and table rows after recoding. A model trained without a new category may not support prediction for that category; mapping it to an existing level solely to obtain a prediction can change the intended meaning.
Retain zero-count allowed levels when they communicate the planned response structure, but distinguish them from unobserved or unavailable fields. Document each newly introduced or retired category. A completed audit should allow a reviewer to reconstruct the vocabulary applicable to any record and explain whether a difference in category frequency reflects the population, the collection instrument or the transformation rules.
Source verification: 6 November 2026. Examples are hypothetical.