From cb39590f618e7c6ff382e76cc461792101a9741a Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Sun, 3 Mar 2024 15:48:05 +0000 Subject: [PATCH] debugging matching for HA28 --- .../ha_15_32/ha_analysis_batch_3.py | 23 +++++++++++++++++++ 1 file changed, 23 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 9bd04884..7481724b 100644 --- a/etl/eligibility/ha_15_32/ha_analysis_batch_3.py +++ b/etl/eligibility/ha_15_32/ha_analysis_batch_3.py @@ -214,6 +214,13 @@ class DataLoader: asset_list["Postcode"].astype(str).str.lower().str.strip() ) asset_list["matching_postcode"] = asset_list["Postcode"].astype(str).str.lower().str.strip() + elif ha_name == "HA28": + asset_list["matching_address"] = ( + asset_list["House Number"].astype(str).str.lower().str.strip() + ", " + + asset_list["Street 1"].astype(str).str.lower().str.strip() + ", " + + asset_list["Postcode"].astype(str).str.lower().str.strip() + ) + asset_list["matching_postcode"] = asset_list["Postcode"].astype(str).str.lower().str.strip() elif ha_name == "HA32": asset_list["matching_address"] = ( asset_list["Dwelling num"].astype(str).str.lower().str.strip() + ", " + @@ -323,6 +330,8 @@ class DataLoader: asset_list["HouseNo"] = asset_list["House No"].copy() elif ha_name == "HA32": asset_list["HouseNo"] = asset_list["Dwelling num"].copy() + elif ha_name == "HA28": + asset_list["HouseNo"] = asset_list["House Number"].copy() else: split_addresses = asset_list['matching_address'].str.split(',', expand=True) house_numbers = split_addresses[0].str.split(' ', expand=True) @@ -371,6 +380,8 @@ class DataLoader: def get_asset_sheetname(workbook): if "Asset List" in workbook.sheetnames: return "Asset List" + elif "Asset list" in workbook.sheetnames: + return "Asset list" elif "Asset" in workbook.sheetnames and "Assets" not in workbook.sheetnames: return "Asset" elif "Decent Homes Stock" in workbook.sheetnames: @@ -394,6 +405,8 @@ class DataLoader: def get_survey_sheetname(workbook): if "ECO Surveys" in workbook.sheetnames: return "ECO Surveys" + elif "ECO Survey" in workbook.sheetnames: + return "ECO Survey" else: return "ECO surveys" @@ -870,6 +883,12 @@ class DataLoader: return survey_list + @staticmethod + def correct_ha28_survey_list(survey_list): + # Rename the "No" column to "No." to align with the other survey sheets + survey_list = survey_list.rename(columns={"NO ": "NO."}) + return survey_list + @staticmethod def correct_ha32_survey_list(survey_list): survey_list["Street / Block Name"] = np.where( @@ -1027,6 +1046,10 @@ class DataLoader: asset_list["matching_address"].str.contains(row["Street / Block Name"].lower().strip()) ].copy() + if str(house_number) not in df["matching_address"].values: + if "flat" in str(house_number): + house_number = house_number.split("flat")[1].strip() + df = df[df["matching_address"].str.contains(str(house_number))] if df.empty: