From 7f88f0e0f59e584d82a6799671e8f1a64a034392 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Thu, 7 Mar 2024 13:59:32 +0000 Subject: [PATCH] Added in the re-labelling of assets based on eco3 merge --- .../ha_15_32/ha_analysis_batch_3.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/etl/eligibility/ha_15_32/ha_analysis_batch_3.py b/etl/eligibility/ha_15_32/ha_analysis_batch_3.py index 7ad50583..21509923 100644 --- a/etl/eligibility/ha_15_32/ha_analysis_batch_3.py +++ b/etl/eligibility/ha_15_32/ha_analysis_batch_3.py @@ -1812,6 +1812,7 @@ class DataLoader: asset_list = data_assets["asset_list"].copy() survey_list = data_assets["survey_list"].copy() ciga_list = data_assets["ciga_list"].copy() + eco3_list = data_assets.get("eco3_list", pd.DataFrame()) asset_list_starting_size = asset_list.shape[0] @@ -1859,6 +1860,25 @@ class DataLoader: if asset_list.shape[0] != asset_list_starting_size: raise ValueError("The asset list has changed in size") + # If we have eco3 surveys, we set a property to not eligible + if not eco3_list.empty: + eco3_list_to_merge = eco3_list[["asset_list_row_id"]].copy() + eco3_list_to_merge["has_eco3"] = True + asset_list = asset_list.merge( + eco3_list_to_merge, how="left", on="asset_list_row_id" + ) + + if asset_list.shape[0] != asset_list_starting_size: + raise ValueError("The asset list has changed in size, when merging on eco3") + + # Any rows that have an eco3 survey are set to not eligible + asset_list["ECO Eligibility"] = np.where( + asset_list["has_eco3"] == True, + "not eligible", + asset_list["ECO Eligibility"] + ) + asset_list = asset_list.drop(columns=["has_eco3"]) + # Report on sales sales_report = {} if not survey_list.empty: