Added grandfathering of v1.0 DACS

This commit is contained in:
Carlos Felix 2024-12-04 10:00:14 -05:00 committed by Carlos Felix
commit e0bb33211a
13 changed files with 74271 additions and 15 deletions

View file

@ -4,6 +4,7 @@ ISLAND_AREAS_PERCENTILE_ADJUSTMENT_FIELD = " for island areas"
ADJACENT_MEAN_SUFFIX = " (based on adjacency index and low income alone)"
ADJACENCY_INDEX_SUFFIX = " (average of neighbors)"
ISLAND_AREA_BACKFILL_SUFFIX = " in 2009"
V1_0_RESULTS_SUFFIX = " v1.0"
# Geographic field names
GEOID_TRACT_FIELD = "GEOID10_TRACT"
@ -27,6 +28,10 @@ N_NON_WORKFORCE = "Any Non-Workforce Factor (Definition N)"
FINAL_SCORE_N_BOOLEAN = (
"Definition N community, including adjacency index tracts"
)
FINAL_SCORE_N_BOOLEAN_V1_0 = f"{FINAL_SCORE_N_BOOLEAN}{V1_0_RESULTS_SUFFIX}"
GRANDFATHERED_N_COMMUNITIES_V1_0 = (
f"Grandfathered {SCORE_N_COMMUNITIES} from v1.0"
)
PERCENTILE = 90
MEDIAN_HOUSE_VALUE_PERCENTILE = 90

View file

@ -1024,6 +1024,20 @@ class ScoreNarwhal(Score):
self.df[field_names.SCORE_N_COMMUNITIES],
)
def _mark_grandfathered_dacs(self) -> None:
"""Territory tracts that are flagged as DACS in the V1.0 score are also marked."""
self.df[field_names.GRANDFATHERED_N_COMMUNITIES_V1_0] = np.where(
self.df[field_names.FINAL_SCORE_N_BOOLEAN_V1_0]
& ~self.df[field_names.FINAL_SCORE_N_BOOLEAN],
True,
False,
)
self.df[field_names.FINAL_SCORE_N_BOOLEAN] = np.where(
self.df[field_names.FINAL_SCORE_N_BOOLEAN_V1_0],
True,
self.df[field_names.FINAL_SCORE_N_BOOLEAN],
)
def _mark_poverty_flag(self) -> None:
"""Combine poverty less than 200% for territories and update the income flag."""
# First we set the low income flag for non-territories by themselves, this
@ -1111,6 +1125,7 @@ class ScoreNarwhal(Score):
] = self.df[field_names.SCORE_N_COMMUNITIES].astype(int)
self._mark_donut_hole_tracts()
self._mark_grandfathered_dacs()
self.df[
field_names.PERCENT_OF_TRACT_IS_DAC
] = self._get_percent_of_tract_that_is_dac()