Skip to content

Commit

Permalink
Add income back, adjust test (#1882)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbowen-usds committed Sep 28, 2022
1 parent 6c049ed commit f11252e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions data/data-pipeline/data_pipeline/etl/score/etl_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,10 @@ def _backfill_island_demographics(self, df: pd.DataFrame) -> pd.DataFrame:
]
df = df.drop(columns=self.ISLAND_DEMOGRAPHIC_BACKFILL_FIELDS)

df.loc[island_index, field_names.TOTAL_POP_FIELD] = df.loc[
island_index, field_names.COMBINED_CENSUS_TOTAL_POPULATION_2010
]

return df

def transform(self) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ def extract(self) -> None:
island["fips"],
county,
)
logger.debug(f"CENSUS: Requesting {api_url}")
download = requests.get(
api_url,
timeout=settings.REQUESTS_DEFAULT_TIMOUT,
Expand Down
11 changes: 10 additions & 1 deletion data/data-pipeline/data_pipeline/tests/score/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
import pandas as pd
import numpy as np
from data_pipeline.etl.score import constants
from data_pipeline.score import field_names
from data_pipeline.score.field_names import GEOID_TRACT_FIELD
from data_pipeline.etl.score.constants import TILES_ISLAND_AREA_FIPS_CODES
Expand Down Expand Up @@ -383,8 +384,16 @@ def test_imputed_tracts(final_score_df):
)

# Make sure that no tracts with population have null imputed income
# We DO NOT impute income
is_island_area = (
final_score_df[field_names.GEOID_TRACT_FIELD]
.str[:2]
.isin(constants.TILES_ISLAND_AREA_FIPS_CODES)
)

tracts_with_some_population_df = final_score_df[
final_score_df[field_names.TOTAL_POP_FIELD] > 0
(final_score_df[field_names.TOTAL_POP_FIELD] > 0)
& ~is_island_area
]
assert (
not tracts_with_some_population_df[
Expand Down

0 comments on commit f11252e

Please sign in to comment.