Issue 844: Add island areas to Definition L (#957)

This ended up being a pretty large task. Here's what this PR does:

1. Pulls in Vincent's data from island areas into the score ETL. This is from the 2010 decennial census, the last census of any kind in the island areas.
2. Grabs a few new fields from 2010 island areas decennial census.
3. Calculates area median income for island areas.
4. Stops using EJSCREEN as the source of our high school education data and directly pulls that from census (this was related to this project so I went ahead and fixed it).
5. Grabs a bunch of data from the 2010 ACS in the states/Puerto Rico/DC, so that we can create percentiles comparing apples-to-apples (ish) from 2010 island areas decennial census data to 2010 ACS data. This required creating a new class because all the ACS fields are different between 2010 and 2019, so it wasn't as simple as looping over a year parameter.
6. Creates a combined population field of island areas and mainland so we can use those stats in our comparison tool, and updates the comparison tool accordingly.
This commit is contained in:
Lucas Merrill Brown 2021-12-03 15:46:10 -05:00 committed by GitHub
commit 1d101c93d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 882 additions and 153 deletions

View file

@ -21,7 +21,7 @@
"from data_pipeline.etl.sources.census.etl_utils import get_state_fips_codes\n",
"\n",
"\n",
"ACS_YEAR = 2019\n",
"ACS_YEAR = 2010\n",
"\n",
"DATA_PATH = Path.cwd().parent / \"data\"\n",
"FIPS_CSV_PATH = DATA_PATH / \"fips_states_2010.csv\"\n",
@ -45,11 +45,13 @@
"source": [
"# Following the tutorial at https://jtleider.github.io/censusdata/example1.html.\n",
"# Full list of fields is at https://www2.census.gov/programs-surveys/acs/summary_file/2019/documentation/user_tools/ACS2019_Table_Shells.xlsx\n",
"censusdata.printtable(\n",
" censusdata.censustable(src=\"acs5\", year=ACS_YEAR, table=\"B25077\")\n",
")\n",
"# censusdata.printtable(\n",
"# censusdata.censustable(src=\"acs5\", year=ACS_YEAR, table=\"B25077\")\n",
"# )\n",
"\n",
"# censusdata.search(src=\"acs5\", year=ACS_YEAR, field='label', criterion='Owner-occupied units!!Median')"
"censusdata.search(\n",
" src=\"acs5\", year=ACS_YEAR, field=\"label\", criterion=\"employment status\"\n",
")"
]
},
{

View file

@ -3,7 +3,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "51412a14",
"metadata": {
"scrolled": true
},
@ -49,7 +48,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e3234c61",
"metadata": {
"scrolled": true
},
@ -81,7 +79,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3b1b5ccf",
"metadata": {
"scrolled": true
},
@ -108,7 +105,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "1b1083e8",
"metadata": {},
"outputs": [],
"source": [
@ -142,7 +138,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "fec0ed63",
"metadata": {},
"outputs": [],
"source": [
@ -165,7 +160,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d9968187",
"metadata": {
"scrolled": false
},
@ -192,7 +186,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a7cfeb3c",
"metadata": {
"scrolled": false
},
@ -222,7 +215,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "df458f08",
"metadata": {},
"outputs": [],
"source": [
@ -255,7 +247,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a6c85d87",
"metadata": {
"scrolled": false
},
@ -282,7 +273,7 @@
" raise ValueError(\"Some of the census tract data has the wrong length.\")\n",
"\n",
"if len(merged_df) > ExtractTransformLoad.EXPECTED_MAX_CENSUS_TRACTS:\n",
" raise ValueError(\"Too many rows in the join.\")\n",
" raise ValueError(f\"Too many rows in the join: {len(merged_df)}.\")\n",
"\n",
"merged_df.head()"
]
@ -290,7 +281,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "274f6bc6",
"metadata": {
"scrolled": true
},
@ -393,17 +383,17 @@
"ejscreen_areas_of_concern_census_block_group_indices = [\n",
" Index(\n",
" method_name=\"EJSCREEN Areas of Concern, National, 80th percentile\",\n",
" priority_communities_field=field_names.EJSCREEN_AREAS_OF_CONCERN_NATIONAL_80TH_PERCENTILE_COMMUNITIES_FIELD_NAME,\n",
" priority_communities_field=field_names.EJSCREEN_AREAS_OF_CONCERN_NATIONAL_80TH_PERCENTILE_COMMUNITIES_FIELD,\n",
" other_census_tract_fields_to_keep=[],\n",
" ),\n",
" Index(\n",
" method_name=\"EJSCREEN Areas of Concern, National, 90th percentile\",\n",
" priority_communities_field=field_names.EJSCREEN_AREAS_OF_CONCERN_NATIONAL_90TH_PERCENTILE_COMMUNITIES_FIELD_NAME,\n",
" priority_communities_field=field_names.EJSCREEN_AREAS_OF_CONCERN_NATIONAL_90TH_PERCENTILE_COMMUNITIES_FIELD,\n",
" other_census_tract_fields_to_keep=[],\n",
" ),\n",
" Index(\n",
" method_name=\"EJSCREEN Areas of Concern, National, 95th percentile\",\n",
" priority_communities_field=field_names.EJSCREEN_AREAS_OF_CONCERN_NATIONAL_95TH_PERCENTILE_COMMUNITIES_FIELD_NAME,\n",
" priority_communities_field=field_names.EJSCREEN_AREAS_OF_CONCERN_NATIONAL_95TH_PERCENTILE_COMMUNITIES_FIELD,\n",
" other_census_tract_fields_to_keep=[],\n",
" ),\n",
"]\n",
@ -439,7 +429,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "bfae9cf5",
"metadata": {
"scrolled": true
},
@ -457,7 +446,8 @@
"\n",
" # Calculate the population included as priority communities per tract. Will either be 0 or the population.\n",
" df[f\"{priority_communities_field}{POPULATION_SUFFIX}\"] = (\n",
" df[priority_communities_field] * df[field_names.TOTAL_POP_FIELD]\n",
" df[priority_communities_field]\n",
" * df[field_names.COMBINED_CENSUS_TOTAL_POPULATION_2010]\n",
" )\n",
"\n",
" def calculate_state_comparison(\n",
@ -496,7 +486,9 @@
" summary_dict[\"Geography name\"] = division_id\n",
"\n",
" total_tracts_in_geography = len(frame)\n",
" total_population_in_geography = frame[field_names.TOTAL_POP_FIELD].sum()\n",
" total_population_in_geography = frame[\n",
" field_names.COMBINED_CENSUS_TOTAL_POPULATION_2010\n",
" ].sum()\n",
"\n",
" if geography_field == field_names.URBAN_HEURISTIC_FIELD:\n",
" urban_flag = frame[field_names.URBAN_HEURISTIC_FIELD].unique()[0]\n",
@ -719,7 +711,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c4d0e783",
"metadata": {},
"outputs": [],
"source": [
@ -825,7 +816,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8790cd64",
"metadata": {
"scrolled": true
},
@ -1024,7 +1014,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "eeb9699d",
"metadata": {
"scrolled": true
},
@ -1201,7 +1190,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "983abcea",
"metadata": {},
"outputs": [],
"source": [