mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-02-23 01:54:18 -08:00
Update backend for Puerto Rico (#1686)
* Update PR threshold count to 10 We now show 10 indicators for PR. See the discussion on the github issue for more info: https://github.com/usds/justice40-tool/issues/1621 * Do not use linguistic iso for Puerto Rico Closes 1350. Co-authored-by: Shelby Switzer <shelbyswitzer@gmail.com>
This commit is contained in:
parent
1782d022a9
commit
05748c9fa2
2 changed files with 50 additions and 8 deletions
|
@ -123,7 +123,7 @@ TILES_ROUND_NUM_DECIMALS = 2
|
|||
# Controlling Tile user experience columns
|
||||
THRESHOLD_COUNT_TO_SHOW_FIELD_NAME = "THRHLD"
|
||||
TILES_ISLAND_AREAS_THRESHOLD_COUNT = 3
|
||||
TILES_PUERTO_RICO_THRESHOLD_COUNT = 4
|
||||
TILES_PUERTO_RICO_THRESHOLD_COUNT = 10
|
||||
TILES_NATION_THRESHOLD_COUNT = 21
|
||||
|
||||
# Note that the FIPS code is a string
|
||||
|
|
|
@ -551,7 +551,7 @@ class ScoreNarwhal(Score):
|
|||
# Where the percent of households at or below 100% of the federal poverty level
|
||||
# is above Xth percentile
|
||||
# or
|
||||
# Where linguistic isolation is above Xth percentile
|
||||
# Where linguistic isolation is above Xth percentile (except PR)
|
||||
# AND
|
||||
# Where the high school degree achievement rates for adults 25 years and older
|
||||
# is less than Y%
|
||||
|
@ -566,6 +566,12 @@ class ScoreNarwhal(Score):
|
|||
field_names.LOW_MEDIAN_INCOME_LOW_HS_EDUCATION_FIELD,
|
||||
]
|
||||
|
||||
pr_workforce_eligibility_columns = [
|
||||
field_names.UNEMPLOYMENT_LOW_HS_EDUCATION_FIELD,
|
||||
field_names.POVERTY_LOW_HS_EDUCATION_FIELD,
|
||||
field_names.LOW_MEDIAN_INCOME_LOW_HS_EDUCATION_FIELD,
|
||||
]
|
||||
|
||||
self.df[field_names.LOW_HS_EDUCATION_FIELD] = (
|
||||
self.df[field_names.HIGH_SCHOOL_ED_FIELD]
|
||||
>= self.LACK_OF_HIGH_SCHOOL_MINIMUM_THRESHOLD
|
||||
|
@ -622,9 +628,41 @@ class ScoreNarwhal(Score):
|
|||
& self.df[field_names.LOW_HS_EDUCATION_FIELD]
|
||||
)
|
||||
|
||||
workforce_combined_criteria_for_states = self.df[
|
||||
workforce_eligibility_columns
|
||||
].any(axis="columns")
|
||||
self.df[field_names.WORKFORCE_THRESHOLD_EXCEEDED] = (
|
||||
## First we calculate for the non-island areas
|
||||
(
|
||||
(
|
||||
self.df[field_names.POVERTY_PCTILE_THRESHOLD]
|
||||
| self.df[field_names.UNEMPLOYMENT_PCTILE_THRESHOLD]
|
||||
)
|
||||
| self.df[field_names.LOW_MEDIAN_INCOME_PCTILE_THRESHOLD]
|
||||
)
|
||||
| (
|
||||
self.df[field_names.LINGUISTIC_ISOLATION_PCTILE_THRESHOLD]
|
||||
& (self.df[field_names.GEOID_TRACT_FIELD].str[:2] != constants.TILES_PUERTO_RICO_FIPS_CODE[0] )
|
||||
)
|
||||
)
|
||||
|
||||
# Use only PR combined criteria for rows with PR FIPS code;
|
||||
# otherwise use all criteria.
|
||||
workforce_combined_criteria_for_states = (
|
||||
(
|
||||
(
|
||||
self.df[field_names.GEOID_TRACT_FIELD].str[:2] == constants.TILES_PUERTO_RICO_FIPS_CODE[0]
|
||||
)
|
||||
&
|
||||
self.df[pr_workforce_eligibility_columns].any(axis="columns")
|
||||
)
|
||||
|
|
||||
(
|
||||
(
|
||||
self.df[field_names.GEOID_TRACT_FIELD].str[:2] != constants.TILES_PUERTO_RICO_FIPS_CODE[0]
|
||||
)
|
||||
& self.df[
|
||||
workforce_eligibility_columns
|
||||
].any(axis="columns")
|
||||
)
|
||||
)
|
||||
|
||||
self._increment_total_eligibility_exceeded(
|
||||
workforce_eligibility_columns
|
||||
|
@ -742,17 +780,21 @@ class ScoreNarwhal(Score):
|
|||
|
||||
# Because these criteria are calculated differently for the islands, we also calculate the
|
||||
# thresholds to pass to the FE slightly differently
|
||||
# If it's PR, we don't use linguistic isolation.
|
||||
|
||||
self.df[field_names.WORKFORCE_THRESHOLD_EXCEEDED] = (
|
||||
## First we calculate for the non-island areas
|
||||
(
|
||||
(
|
||||
self.df[field_names.POVERTY_PCTILE_THRESHOLD]
|
||||
| self.df[field_names.LINGUISTIC_ISOLATION_PCTILE_THRESHOLD]
|
||||
| self.df[field_names.UNEMPLOYMENT_PCTILE_THRESHOLD]
|
||||
)
|
||||
| self.df[field_names.LOW_MEDIAN_INCOME_PCTILE_THRESHOLD]
|
||||
)
|
||||
| self.df[field_names.UNEMPLOYMENT_PCTILE_THRESHOLD]
|
||||
| (
|
||||
self.df[field_names.LINGUISTIC_ISOLATION_PCTILE_THRESHOLD]
|
||||
& ( self.df[field_names.GEOID_TRACT_FIELD].str[:2] != constants.TILES_PUERTO_RICO_FIPS_CODE[0] )
|
||||
)
|
||||
) | (
|
||||
## then we calculate just for the island areas
|
||||
(
|
||||
|
@ -777,7 +819,7 @@ class ScoreNarwhal(Score):
|
|||
)
|
||||
|
||||
def add_columns(self) -> pd.DataFrame:
|
||||
logger.info("Adding Score M")
|
||||
logger.info("Adding Score Narhwal")
|
||||
|
||||
self.df[field_names.THRESHOLD_COUNT] = 0
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue