Adding persistent poverty tracts (#738)

* persistent poverty working

* fixing left-padding

* running black and adding persistent poverty to comp tool

* fixing bug

* running black and fixing linter

* fixing linter

* fixing linter error
This commit is contained in:
Lucas Merrill Brown 2021-09-22 16:57:08 -05:00 committed by GitHub
commit b1a4d26be8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 518 additions and 201 deletions

View file

@ -20,7 +20,7 @@
"module_path = os.path.abspath(os.path.join(\"..\"))\n",
"if module_path not in sys.path:\n",
" sys.path.append(module_path)\n",
" \n",
"\n",
"from data_pipeline.utils import unzip_file_from_url\n",
"from data_pipeline.etl.sources.census.etl_utils import get_state_fips_codes"
],
@ -57,9 +57,16 @@
"cell_type": "code",
"execution_count": null,
"source": [
"counties_df = pd.read_csv(CENSUS_COUNTIES_TXT, sep=\"\\t\", dtype={\"GEOID\": \"string\", \"USPS\": \"string\"}, low_memory=False)\n",
"counties_df = counties_df[['USPS', 'GEOID', 'NAME']]\n",
"counties_df.rename(columns={\"USPS\": \"State Abbreviation\", \"NAME\": \"County Name\"}, inplace=True)\n",
"counties_df = pd.read_csv(\n",
" CENSUS_COUNTIES_TXT,\n",
" sep=\"\\t\",\n",
" dtype={\"GEOID\": \"string\", \"USPS\": \"string\"},\n",
" low_memory=False,\n",
")\n",
"counties_df = counties_df[[\"USPS\", \"GEOID\", \"NAME\"]]\n",
"counties_df.rename(\n",
" columns={\"USPS\": \"State Abbreviation\", \"NAME\": \"County Name\"}, inplace=True\n",
")\n",
"counties_df.head()"
],
"outputs": [],
@ -69,8 +76,17 @@
"cell_type": "code",
"execution_count": null,
"source": [
"states_df = pd.read_csv(STATE_CSV, dtype={\"fips\": \"string\", \"state_abbreviation\": \"string\"})\n",
"states_df.rename(columns={\"fips\": \"State Code\", \"state_name\": \"State Name\", \"state_abbreviation\": \"State Abbreviation\"}, inplace=True)\n",
"states_df = pd.read_csv(\n",
" STATE_CSV, dtype={\"fips\": \"string\", \"state_abbreviation\": \"string\"}\n",
")\n",
"states_df.rename(\n",
" columns={\n",
" \"fips\": \"State Code\",\n",
" \"state_name\": \"State Name\",\n",
" \"state_abbreviation\": \"State Abbreviation\",\n",
" },\n",
" inplace=True,\n",
")\n",
"states_df.head()"
],
"outputs": [],
@ -80,7 +96,7 @@
"cell_type": "code",
"execution_count": null,
"source": [
"county_state_merged = counties_df.join(states_df, rsuffix=' Other')\n",
"county_state_merged = counties_df.join(states_df, rsuffix=\" Other\")\n",
"del county_state_merged[\"State Abbreviation Other\"]\n",
"county_state_merged.head()"
],
@ -102,7 +118,7 @@
"cell_type": "code",
"execution_count": null,
"source": [
"score_county_state_merged = score_df.join(county_state_merged, rsuffix='_OTHER')\n",
"score_county_state_merged = score_df.join(county_state_merged, rsuffix=\"_OTHER\")\n",
"del score_county_state_merged[\"GEOID_OTHER\"]\n",
"score_county_state_merged.head()"
],