From b63c465885d203d6e02718fdc9a0c0dd87155c66 Mon Sep 17 00:00:00 2001 From: Emma Nechamkin Date: Thu, 25 Aug 2022 17:15:33 -0400 Subject: [PATCH] adding a check to the agvalue calculation for nri --- .../etl/sources/national_risk_index/etl.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/data/data-pipeline/data_pipeline/etl/sources/national_risk_index/etl.py b/data/data-pipeline/data_pipeline/etl/sources/national_risk_index/etl.py index 0b7ff12e..d1373602 100644 --- a/data/data-pipeline/data_pipeline/etl/sources/national_risk_index/etl.py +++ b/data/data-pipeline/data_pipeline/etl/sources/national_risk_index/etl.py @@ -153,6 +153,19 @@ class NationalRiskIndexETL(ExtractTransformLoad): lower=self.AGRIVALUE_LOWER_BOUND ) + ## Check that this clip worked -- that the only place the value has changed is when the clip took effect + base_expectation = ( + disaster_agriculture_sum_series + / df_nri[self.AGRICULTURAL_VALUE_INPUT_FIELD_NAME] + ) + assert ( + df_nri[ + df_nri[self.EXPECTED_AGRICULTURE_LOSS_RATE_FIELD_NAME] + != base_expectation + ][self.AGRICULTURAL_VALUE_INPUT_FIELD_NAME].max() + < self.AGRIVALUE_LOWER_BOUND + ) + # This produces a boolean that is True in the case of non-zero agricultural value df_nri[self.CONTAINS_AGRIVALUE] = ( df_nri[self.AGRICULTURAL_VALUE_INPUT_FIELD_NAME] > 0