Last active
May 7, 2025 06:05
-
-
Save jss367/44e041c913f87a11b2830e01e295c241 to your computer and use it in GitHub Desktop.
census_popgroup_dict.py
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
""" | |
US Census Race and Hispanic Origin Iteration Codes | |
""" | |
# Dictionary mapping iteration codes to population descriptions | |
code_to_population = { | |
# Total Population | |
"001": "Total Population", | |
# Race alone | |
"002": "White alone", | |
"003": "White alone or in combination with one or more other races", | |
"004": "Black or African American alone", | |
"005": "Black or African American alone or in combination with one or more other races", | |
"006": "American Indian and Alaska Native alone (300, A01-Z99)", | |
"009": "American Indian and Alaska Native alone or in combination with one or more other races", | |
"012": "Asian alone", | |
"013": "Asian Indian alone", | |
"014": "Bangladeshi alone", | |
"015": "Cambodian alone", | |
"016": "Chinese alone", | |
"017": "Chinese (except Taiwanese) alone", | |
"018": "Taiwanese alone", | |
"019": "Filipino alone", | |
"020": "Hmong alone", | |
"021": "Indonesian alone", | |
"022": "Japanese alone", | |
"023": "Korean alone", | |
"024": "Laotian alone", | |
"025": "Malaysian alone", | |
"026": "Pakistani alone", | |
"027": "Sri Lankan alone", | |
"028": "Thai alone", | |
"029": "Vietnamese alone", | |
"031": "Asian alone or in combination with one or more other races", | |
"050": "Native Hawaiian and Other Pacific Islander alone", | |
"051": "Polynesian alone", | |
"052": "Native Hawaiian alone", | |
"053": "Samoan alone", | |
"054": "Tongan alone", | |
"055": "Micronesian alone", | |
"056": "Guamanian or Chamorro alone", | |
"057": "Melanesian alone", | |
"058": "Fijian alone", | |
"060": "Native Hawaiian and Other Pacific Islander alone or in combination with one or more other races", | |
"070": "Some Other Race alone", | |
"071": "Some Other Race alone or in combination with one or more other races", | |
# Two or More Races | |
"100": "Two or More Races", | |
"101": "Two races with Some Other Race", | |
"103": "Two races without Some Other Race", | |
"104": "Three or more races", | |
"105": "White; Black or African American", | |
"106": "White; American Indian and Alaska Native", | |
"107": "White; Asian", | |
"108": "White; Native Hawaiian and Other Pacific Islander", | |
"109": "White; Some Other Race", | |
"110": "Black or African American; American Indian and Alaska Native", | |
"111": "Black or African American; Asian", | |
"112": "Black or African American; Native Hawaiian and Other Pacific Islander", | |
"113": "Black or African American; Some Other Race", | |
"114": "American Indian and Alaska Native; Asian", | |
"115": "American Indian and Alaska Native; Native Hawaiian and Other Pacific Islander", | |
"116": "American Indian and Alaska Native; Some Other Race", | |
"117": "Asian; Native Hawaiian and Other Pacific Islander", | |
"118": "Asian; Some Other Race", | |
"119": "Native Hawaiian and Other Pacific Islander; Some Other Race", | |
# Hispanic or Latino Origin | |
"400": "Hispanic or Latino (of any race)", | |
"401": "Mexican (210-220)", | |
"402": "Puerto Rican", | |
"403": "Cuban", | |
"404": "Other Hispanic or Latino", | |
"405": "Dominican (Dominican Republic)", | |
"406": "Central American (excludes Mexican)", | |
"407": "Costa Rican (221)", | |
"408": "Guatemalan (222)", | |
"409": "Honduran (223)", | |
"410": "Nicaraguan (224)", | |
"411": "Panamanian (225)", | |
"412": "Salvadoran", | |
"413": "South American", | |
"414": "Argentinean (231)", | |
"415": "Bolivian (232)", | |
"416": "Chilean (233)", | |
"417": "Colombian (234)", | |
"418": "Ecuadorian (235)", | |
"419": "Paraguayan (236)", | |
"420": "Peruvian (237)", | |
"421": "Uruguayan (238)", | |
"422": "Venezuelan (239)", | |
"423": "Spaniard (200-209)", | |
"450": "Not Hispanic or Latino", | |
"451": "White alone, not Hispanic or Latino", | |
"452": "White alone or in combination with one or more other races, not Hispanic or Latino", | |
"453": "Black or African American alone, not Hispanic or Latino", | |
"454": "Black or African American alone or in combination with one or more other races, not Hispanic or Latino", | |
"455": "American Indian and Alaska Native alone, not Hispanic or Latino", | |
"456": "American Indian and Alaska Native alone or in combination with one or more other races, not Hispanic or Latino", | |
"457": "Asian alone, not Hispanic or Latino", | |
"458": "Asian alone or in combination with one or more other races, not Hispanic or Latino", | |
"459": "Native Hawaiian and Other Pacific Islander alone, not Hispanic or Latino", | |
"460": "Native Hawaiian and Other Pacific Islander alone or in combination with one or more other races, not Hispanic or Latino", | |
"461": "Some Other Race alone, not Hispanic or Latino", | |
"462": "Some Other Race alone or in combination with one or more other races, not Hispanic or Latino", | |
"463": "Two or More Races, not Hispanic or Latino", | |
"464": "White alone, Hispanic or Latino", | |
"465": "White alone or in combination with one or more other races, Hispanic or Latino", | |
"466": "Black or African American alone, Hispanic or Latino", | |
"467": "Black or African American alone or in combination with one or more other races, Hispanic or Latino", | |
"468": "American Indian and Alaska Native alone, Hispanic or Latino", | |
"469": "American Indian and Alaska Native alone or in combination with one or more other races, Hispanic or Latino", | |
"470": "Asian alone, Hispanic or Latino", | |
"471": "Asian alone or in combination with one or more other races, Hispanic or Latino", | |
"472": "Native Hawaiian and Other Pacific Islander alone, Hispanic or Latino", | |
"473": "Native Hawaiian and Other Pacific Islander alone or in combination with one or more other races, Hispanic or Latino", | |
"474": "Some Other Race alone, Hispanic or Latino", | |
"475": "Some Other Race alone or in combination with one or more other races, Hispanic or Latino", | |
"476": "Two or More Races, Hispanic or Latino", | |
} | |
# Dictionary mapping population descriptions to iteration codes | |
population_to_code = {v: k for k, v in code_to_population.items()} | |
def get_population_by_code(code): | |
""" | |
Get the population description for a given iteration code. | |
""" | |
# Convert to string if it's an integer | |
code = str(code) | |
return code_to_population.get(code) | |
def get_code_by_population(population): | |
""" | |
Get the iteration code for a given population description. | |
""" | |
return population_to_code.get(population) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment