From b26e44b465e5c832a65b5bd09767f1015c2dfc1a Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 27 Feb 2024 15:45:33 +0000 Subject: [PATCH] Extending to HA 7 --- .../ha_15_32/ha_analysis_batch_3.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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 da484daa..2fb26e73 100644 --- a/etl/eligibility/ha_15_32/ha_analysis_batch_3.py +++ b/etl/eligibility/ha_15_32/ha_analysis_batch_3.py @@ -48,6 +48,10 @@ PROPERTY_TYPE_LOOKUP = { 'EXTRACARE SCHEME': "Flat", } }, + "HA7": { + "property_type": {}, + "built_form": {} + }, "HA14": { "property_type": { "House": "House", @@ -143,6 +147,13 @@ class DataLoader: asset_list["matching_postcode"] = asset_list[ self.COLUMN_CONFIG[ha_name]["postcode"] ].str.lower().str.strip() + elif ha_name == "HA7": + # Create matching_address by concatenating Address 1, Address 2, Address 3, Address 4, Postcode + asset_list["matching_address"] = asset_list["Address"].str.lower().str.strip() + ", " + \ + asset_list["Address2"].str.lower().str.strip() + ", " + \ + asset_list["Address3"].str.lower().str.strip() + ", " + \ + asset_list["Postcode"].str.lower().str.strip() + asset_list["matching_postcode"] = asset_list["Postcode"].str.lower().str.strip() elif ha_name == "HA14": # Create matching_address by concatenating Address 1, Address 2, Address 3, Address 4, Postcode asset_list["matching_address"] = asset_list["Address 1"].str.lower().str.strip() + ", " + \ @@ -241,6 +252,8 @@ class DataLoader: def get_asset_sheetname(workbook): if "Asset List" in workbook.sheetnames: return "Asset List" + elif "Asset" in workbook.sheetnames and "Assets" not in workbook.sheetnames: + return "Asset" else: return "Assets" @@ -311,6 +324,8 @@ class DataLoader: survey_list = pd.DataFrame(survey_rows, columns=[cell.value for cell in survey_sheet[1]]) # Remove columns that are None survey_list = survey_list.loc[:, survey_list.columns.notnull()] + # Remove rows that are completely empty + survey_list = survey_list.loc[survey_list.loc[:, survey_list.columns].notnull().any(axis=1)] survey_list["survey_list_row_id"] = [ha_name + "_survey_" + str(i) for i in range(0, len(survey_list))] # Perform survey list merge @@ -328,6 +343,8 @@ class DataLoader: ciga_list = pd.DataFrame(ciga_rows, columns=[cell.value for cell in ciga_sheet[1]]) # Remove columns that are None ciga_list = ciga_list.loc[:, ciga_list.columns.notnull()] + # Remove rows that are completely None + ciga_list = ciga_list.loc[ciga_list.loc[:, ciga_list.columns].notnull().any(axis=1)] # Perform ciga list merge if not ciga_list.empty: # Remove rows with missing postcode which happens in a small number of cases @@ -1880,7 +1897,7 @@ def app(): # Grab the December HA figures filepath december_figures_filepath = "local_data/ha_data/HA_December_figures.csv" - priority_has = ["HA1", "HA6", "HA14", "HA39", "HA107"] + priority_has = ["HA1", "HA6", "HA7", "HA14", "HA39", "HA107"] # Filter down the directories to only the priority HAs directories = [d for d in directories if d.split("/")[2] in priority_has]