Restore string enum labels in UKSingleYearDataset.person/benunit/household#1498
Merged
nwoodruff-co merged 4 commits intomainfrom Feb 19, 2026
Merged
Restore string enum labels in UKSingleYearDataset.person/benunit/household#1498nwoodruff-co merged 4 commits intomainfrom
nwoodruff-co merged 4 commits intomainfrom
Conversation
…m labels After the warm-load caching optimisation (#1497), enum columns in dataset DataFrames are stored as int16 for performance. Add decoded_person, decoded_benunit and decoded_household properties to UKSingleYearDataset that return copies of the DataFrames with enum columns decoded back to their string names (e.g. 0 -> 'MALE'). The internal int16 representation is unchanged so simulation performance is unaffected.
…ings Replace plain DataFrame attributes with properties that decode int16 enum columns back to string names on access. The raw int16 data is stored in private _person/_benunit/_household attributes and accessed via .tables by the simulation engine, preserving the warm-load performance gain from #1497. Callers (e.g. sim.dataset[year].person) now see string labels as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
int16internally for the warm-load cache speedup, breakingsim.dataset[year].personfor callers who expected string labels like'MALE'/'FT_EMPLOYED'person,benunit,householdonUKSingleYearDatasetfrom plain attributes to properties that decodeint16enum columns back to strings on accessint16data lives in private_person/_benunit/_household;.tables(used by the simulation engine) still points at these, so no performance regression_pre_encode_enum_columnsinsimulation.pyupdated to write to_<table>directlyTest plan
sim.dataset[year].person['gender'].valuesreturns['MALE', 'FEMALE', ...]not integerssim.dataset[year]._person['gender'].dtypeisint16