Skip to content

Commit

Permalink
Backfill population in island areas (#1882)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbowen-usds committed Sep 23, 2022
1 parent 9e85375 commit f096184
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion data/data-pipeline/data_pipeline/etl/score/etl_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def _prepare_initial_df(self) -> pd.DataFrame:
self.nature_deprived_df,
self.eamlis_df,
self.fuds_df,
self.tribal_overlap_df
self.tribal_overlap_df,
]

# Sanity check each data frame before merging.
Expand Down Expand Up @@ -640,8 +640,24 @@ class ReversePercentile:
]
].mean(axis=1, skipna=True)

# For AS, MP, GU, and VI, backfill data from the 2010 census where we have it
df_copy = self._backfill_island_data(df_copy)

return df_copy

@staticmethod
def _backfill_island_data(df: pd.DataFrame) -> pd.DataFrame:
logger.info("Backfilling island data")
island_index = (
df[field_names.GEOID_TRACT_FIELD]
.str[:2]
.isin(constants.TILES_ISLAND_AREA_FIPS_CODES)
)
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:
logger.info("Transforming Score Data")

Expand Down

0 comments on commit f096184

Please sign in to comment.