You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a (semi) standard set of values that are available for each of:
Race/Ethnicity
Gender
Comorbidities/Underlying Conditions
Transmission Categories
(See the data model docs for more on this. Note that age does not have standardized values like this because the categories are so different across counties that we can’t meaningfully bucket them.)
Rather than having strings that could contain typos for these all over the codebase, we should really have a set of constants or (better yet) enums for them, e.g:
# This part should be in a centralized module somewhere.fromenumimportEnumclassRaceEthnicity(Enum):
african_american="African_Amer"asian="Asian"latinx="Latinx_or_Hispanic"native_american="Native_Amer"pacific_islander="Pacific_Islander"white="White"multiple="Multiple_Race"other="Other"unknown="Unknown"# Elsewhere in some scraper code...# This example from Marin (https://github.com/sfbrigade/data-covid19-sfbayarea/blob/5fb99a51fa89ddc3ffacf65c3ae1c1fda19e75e9/covid19_sfbayarea/data/marin.py#L190-L206)# Map the county's naming scheme to ours:mapping= {
'american indian/alaska native': RaceEthnicity.native_american,
'asian': RaceEthnicity.asian,
'black/african american': RaceEthnicity.african_american,
'hispanic/latinx': RaceEthnicity.latinx,
'multiracial': RaceEthnicity.multiple,
'native hawaiian/pacific islander': RaceEthnicity.pacific_islander,
'unknown': RaceEthnicity.unknown,
'other': RaceEthnicity.other,
'white': RaceEthnicity.white,
}
data=get_demographic_totals(api, 'Race')
return {mapping[row['grouping'].lower()]: int(row['cumulative'])
forrowindata}
This way, mypy can check that we haven’t made any typos and our values are consistent across the codebase.
The text was updated successfully, but these errors were encountered:
We have a (semi) standard set of values that are available for each of:
(See the data model docs for more on this. Note that age does not have standardized values like this because the categories are so different across counties that we can’t meaningfully bucket them.)
Rather than having strings that could contain typos for these all over the codebase, we should really have a set of constants or (better yet) enums for them, e.g:
This way, mypy can check that we haven’t made any typos and our values are consistent across the codebase.
The text was updated successfully, but these errors were encountered: