Skip to content

fix(docs): cast strata to str before replace in Oregon tutorial#116

Open
okiner-3 wants to merge 1 commit into
mainfrom
fix/oregon-strata-astype-str
Open

fix(docs): cast strata to str before replace in Oregon tutorial#116
okiner-3 wants to merge 1 commit into
mainfrom
fix/oregon-strata-astype-str

Conversation

@okiner-3

Copy link
Copy Markdown
Collaborator

Summary

The Oregon tutorial's preprocessing step calls .replace() directly on the strata column (renamed from numhh_list). Since numhh_list is a pandas categorical column, mapping its values to 'signed self up + others' (a category that does not exist) raises a type error.

This adds .astype(str) before .replace() so the column is converted to a string type first, avoiding the error.

Changes

df['strata'] = df['strata'].astype(str).replace({
    'signed self up + 1 additional person': 'signed self up + others',
    'signed self up + 2 additional people': 'signed self up + others'
})

numhh_list is a categorical column, so calling .replace() to map values
to a category that does not exist raises a type error. Convert to str
before .replace() to avoid this.
@okiner-3 okiner-3 self-assigned this Jun 19, 2026
@okiner-3 okiner-3 requested a review from TomeHirata June 19, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant