From 928d9c645c080b27d5736b8f95d10940f22031b5 Mon Sep 17 00:00:00 2001 From: Vim USDS Date: Thu, 2 Feb 2023 14:20:48 -0800 Subject: [PATCH] update lead paint - to incorporate missing housing value --- .../data_pipeline/score/score_narwhal.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/data/data-pipeline/data_pipeline/score/score_narwhal.py b/data/data-pipeline/data_pipeline/score/score_narwhal.py index 0849d85a..57a44f92 100644 --- a/data/data-pipeline/data_pipeline/score/score_narwhal.py +++ b/data/data-pipeline/data_pipeline/score/score_narwhal.py @@ -411,21 +411,27 @@ class ScoreNarwhal(Score): # Create a field only used for output. This field is: # (a) the percentile of lead paint, but - # (b) it is set to None for all tracts with >90th percentile median house value. + # (b) it is set to 0 for all tracts with >90th percentile median house value OR + # (c) if the housing value is missing self.df[field_names.LEAD_PAINT_HOUSE_VALUE_FIELD_PCTILE] = np.where( # If house value <= 90th percentile, - self.df[ + (self.df[ field_names.MEDIAN_HOUSE_VALUE_FIELD + field_names.PERCENTILE_FIELD_SUFFIX - ] - <= self.MEDIAN_HOUSE_VALUE_THRESHOLD, + ] + <= self.MEDIAN_HOUSE_VALUE_THRESHOLD) | + # or if house value is missing + (self.df[ + field_names.MEDIAN_HOUSE_VALUE_FIELD + + field_names.PERCENTILE_FIELD_SUFFIX + ].isnull()), # Then show lead paint percentile. self.df[ field_names.LEAD_PAINT_FIELD + field_names.PERCENTILE_FIELD_SUFFIX ], # Otherwise, set to nothing. - None, + 0, ) self.df[field_names.LEAD_PAINT_MEDIAN_HOUSE_VALUE_LOW_INCOME_FIELD] = (