From 3b5ea59b53fb4940b58ba56a42498ce961389c4c Mon Sep 17 00:00:00 2001 From: lucasmbrown-usds Date: Sun, 5 Dec 2021 20:52:50 -0500 Subject: [PATCH] updating field_names, adding extreme heat --- .../data_pipeline/etl/score/etl_score.py | 8 ------- .../data_pipeline/score/field_names.py | 14 ++++++++++++ .../data_pipeline/score/score_l.py | 22 +++++++++++++++++++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/data/data-pipeline/data_pipeline/etl/score/etl_score.py b/data/data-pipeline/data_pipeline/etl/score/etl_score.py index e796cfaf..ff8c6aaf 100644 --- a/data/data-pipeline/data_pipeline/etl/score/etl_score.py +++ b/data/data-pipeline/data_pipeline/etl/score/etl_score.py @@ -168,14 +168,10 @@ class ScoreETL(ExtractTransformLoad): # Load COI data child_opportunity_index_csv = ( -<<<<<<< HEAD constants.DATA_PATH / "dataset" / "child_opportunity_index" / "usa.csv" -======= - constants.DATA_PATH / "dataset" / "child_opportunity_index" / "usa.csv" ->>>>>>> 050a5c30 (added fields to score_etl) ) self.child_opportunity_index_df = pd.read_csv( child_opportunity_index_csv, @@ -364,11 +360,7 @@ class ScoreETL(ExtractTransformLoad): self.census_acs_median_incomes_df, self.census_decennial_df, self.census_2010_df, -<<<<<<< HEAD self.child_opportunity_index_df, -======= - self.child_opportunity_index_df ->>>>>>> 050a5c30 (added fields to score_etl) ] # Sanity check each data frame before merging. diff --git a/data/data-pipeline/data_pipeline/score/field_names.py b/data/data-pipeline/data_pipeline/score/field_names.py index 76d11038..11d2961a 100644 --- a/data/data-pipeline/data_pipeline/score/field_names.py +++ b/data/data-pipeline/data_pipeline/score/field_names.py @@ -236,6 +236,11 @@ LOW_READING_FIELD = "Low third grade reading proficiency" EXPECTED_POPULATION_LOSS_RATE_LOW_INCOME_FIELD = f"At or above the {PERCENTILE}th percentile for expected population loss rate and is low income" EXPECTED_AGRICULTURE_LOSS_RATE_LOW_INCOME_FIELD = f"At or above the {PERCENTILE}th percentile for expected agriculture loss rate and is low income" EXPECTED_BUILDING_LOSS_RATE_LOW_INCOME_FIELD = f"At or above the {PERCENTILE}th percentile for expected building loss rate and is low income" +EXTREME_HEAT_MEDIAN_HOUSE_VALUE_LOW_INCOME_FIELD = ( + f"At or above the {PERCENTILE}th percentile for summer days above 90F and " + f"the median house value is less than {MEDIAN_HOUSE_VALUE_PERCENTILE}th " + f"percentile and is low income" +) # Clean energy and efficiency PM25_EXPOSURE_LOW_INCOME_FIELD = f"At or above the {PERCENTILE}th percentile for PM2.5 exposure and is low income" @@ -275,6 +280,11 @@ LOW_LIFE_EXPECTANCY_LOW_INCOME_FIELD = ( f"for low life expectancy and is low income" ) +HEALTHY_FOOD_LOW_INCOME_FIELD = ( + f"At or above the {PERCENTILE}th percentile for low " + f"access to healthy food and is low income" +) + # Workforce UNEMPLOYMENT_LOW_HS_EDUCATION_FIELD = ( f"At or above the {PERCENTILE}th percentile for unemployment" @@ -317,6 +327,10 @@ HEALTHY_FOOD_LOW_INCOME_FIELD = ( f"At or above the {PERCENTILE}th percentile for low " f"access to healthy food and is low income" ) +READING_LOW_HS_EDUCATION_FIELD = ( + f"At or above the {PERCENTILE}th percentile for 3rd grade reading proficiency" + " and has low HS education" +) THRESHOLD_COUNT = "Total threshold criteria exceeded" diff --git a/data/data-pipeline/data_pipeline/score/score_l.py b/data/data-pipeline/data_pipeline/score/score_l.py index d11267bf..efa4f5c1 100644 --- a/data/data-pipeline/data_pipeline/score/score_l.py +++ b/data/data-pipeline/data_pipeline/score/score_l.py @@ -179,6 +179,7 @@ class ScoreL(Score): field_names.EXPECTED_POPULATION_LOSS_RATE_LOW_INCOME_FIELD, field_names.EXPECTED_AGRICULTURE_LOSS_RATE_LOW_INCOME_FIELD, field_names.EXPECTED_BUILDING_LOSS_RATE_LOW_INCOME_FIELD, + field_names.EXTREME_HEAT_MEDIAN_HOUSE_VALUE_LOW_INCOME_FIELD, ] expected_population_loss_threshold = ( @@ -205,6 +206,20 @@ class ScoreL(Score): >= self.ENVIRONMENTAL_BURDEN_THRESHOLD ) + extreme_heat_median_home_value_threshold = ( + self.df[ + field_names.EXTREME_HEAT_FIELD + + field_names.PERCENTILE_FIELD_SUFFIX + ] + >= self.ENVIRONMENTAL_BURDEN_THRESHOLD + ) & ( + self.df[ + field_names.MEDIAN_HOUSE_VALUE_FIELD + + field_names.PERCENTILE_FIELD_SUFFIX + ] + <= self.MEDIAN_HOUSE_VALUE_THRESHOLD + ) + self.df[field_names.EXPECTED_POPULATION_LOSS_RATE_LOW_INCOME_FIELD] = ( expected_population_loss_threshold & self.df[field_names.FPL_200_SERIES] @@ -220,6 +235,13 @@ class ScoreL(Score): & self.df[field_names.FPL_200_SERIES] ) + self.df[ + field_names.EXTREME_HEAT_MEDIAN_HOUSE_VALUE_LOW_INCOME_FIELD + ] = ( + extreme_heat_median_home_value_threshold + & self.df[field_names.FPL_200_SERIES] + ) + self._increment_total_eligibility_exceeded(climate_eligibility_columns) return self.df[climate_eligibility_columns].any(axis="columns")