Added ha44

This commit is contained in:
Khalim Conn-Kowlessar 2024-03-18 10:40:12 +00:00
parent 9bbcbc881f
commit 897d58eec2

View file

@ -78,6 +78,29 @@ PROPERTY_TYPE_LOOKUP = {
"End Terraced": "End-Terrace",
}
},
"HA8": {
"House": "House",
"Flat": "Flat",
"Bungalow": "Bungalow",
"Maisonette": "Maisonette",
"Bedsit": None,
"Room": None,
"Other": None,
"Commerical": None
},
"HA11": {
"Flat": "Flat",
"House": "House",
"Semi-Det House": "House",
"Bedsit": None,
"End-Terr House": "House",
"Mid-Terr House": "House",
"Bungalow": "Bungalow",
"Maisonette": "Maisonette",
"End Terr Flat": "Flat",
"Mid Terr Flat": "Flat",
"Detached Flat": "Flat",
},
"HA12": {
"House": "House",
"Flat": "Flat",
@ -244,6 +267,13 @@ PROPERTY_TYPE_LOOKUP = {
"3 Bedroom Unknown": None,
"4 Bedroom Unknown": None,
},
"HA37": {
"FLT": "Flat",
"HSE": "House",
"BNW": "Bungalow",
"MAS": "Maisonette",
"HSL": None
},
"HA39": {
"Semi house": {"property_type": "House", "built_form": "Semi-Detached"},
"1st floor flat": {"property_type": "Flat", "built_form": None},
@ -291,6 +321,21 @@ PROPERTY_TYPE_LOOKUP = {
'Bungalow 1919-1945': 'Bungalow',
'Office': None
},
"HA42": {
'Flat': 'Flat',
'House': 'House',
'Flat Basement': 'Flat',
'Room': None,
'Bedsit Flat': 'Flat',
'Maisonette': 'Maisonette',
'Scheme Office': None,
'Scheme Lounge': None,
'Bungalow': 'Bungalow',
'Garage': None,
'Scheme Sleep Room': None,
'Cluster': None,
'Scheme Room': None
},
"HA48": {
"House": "House",
"Flat": "Flat",
@ -626,6 +671,12 @@ class DataLoader:
asset_list["Address Line 4"].astype(str).str.lower().str.strip() + ", " + \
asset_list["Address Post Code"].astype(str).str.lower().str.strip()
asset_list["matching_postcode"] = asset_list["Address Post Code"].astype(str).str.lower().str.strip()
elif ha_name == "HA37":
asset_list["matching_address"] = asset_list["ADDRESS LINE 1"].astype(str).str.lower().str.strip() + ", " + \
asset_list["ADDRESS LINE 2"].astype(str).str.lower().str.strip() + ", " + \
asset_list["ADDRESS LINE 3"].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 == "HA38":
asset_list["matching_address"] = asset_list["House_Number"].astype(str).str.lower().str.strip() + ", " + \
asset_list["Address_Line_1"].astype(str).str.lower().str.strip() + ", " + \
@ -650,6 +701,18 @@ class DataLoader:
asset_list["AddressLine5"].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 == "HA42":
asset_list["matching_address"] = asset_list["Dwelling Number"].astype(str).str.lower().str.strip() + " " + \
asset_list["Street"].astype(str).str.lower().str.strip() + ", " + \
asset_list["Locality"].astype(str).str.lower().str.strip() + ", " + \
asset_list["Town"].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 == "HA44":
asset_list["matching_address"] = asset_list["Address 1"].astype(str).str.lower().str.strip() + ", " + \
asset_list["Address 2"].astype(str).str.lower().str.strip() + ", " + \
asset_list["Postal Code"].astype(str).str.lower().str.strip()
asset_list["matching_postcode"] = asset_list["Postal Code"].astype(str).str.lower().str.strip()
elif ha_name == "HA50":
asset_list["matching_address"] = asset_list["Address Line 1"].astype(str).str.lower().str.strip() + ", " + \
asset_list["Post Code"].astype(str).str.lower().str.strip()
@ -1177,6 +1240,66 @@ class DataLoader:
asset_list["matching_address"]
)
asset_list["HouseNo"] = np.where(
(asset_list["Address_Line_1"].isin(
[
"10 SOUTH VIEW/FLAT C",
]
)),
"10C",
asset_list["HouseNo"]
)
asset_list["matching_address"] = np.where(
(asset_list["Address_Line_1"].isin(
[
"10 SOUTH VIEW/FLAT C",
]
)),
"FLAT c, spennymoor, co. durham, dl16 7df, 10c, 10 south view",
asset_list["matching_address"]
)
asset_list["HouseNo"] = np.where(
(asset_list["Address_Line_1"].isin(
[
"10 SOUTH VIEW/FLAT D",
]
)),
"10D",
asset_list["HouseNo"]
)
asset_list["matching_address"] = np.where(
(asset_list["Address_Line_1"].isin(
[
"10 SOUTH VIEW/FLAT D",
]
)),
"FLAT d, spennymoor, co. durham, dl16 7df, 10d, 10 south view",
asset_list["matching_address"]
)
asset_list["HouseNo"] = np.where(
(asset_list["Address_Line_1"].isin(
[
"10 SOUTH VIEW/FLAT E",
]
)),
"10E",
asset_list["HouseNo"]
)
asset_list["matching_address"] = np.where(
(asset_list["Address_Line_1"].isin(
[
"10 SOUTH VIEW/FLAT E",
]
)),
'FLAT e, spennymoor, co. durham, dl16 7df, 10e, 10 south view',
asset_list["matching_address"]
)
return asset_list
@staticmethod
@ -1730,6 +1853,13 @@ class DataLoader:
survey_list["Street / Block Name"]
)
survey_list["Post Code"] = np.where(
(survey_list["Street / Block Name"] == "BEECH ROAD") &
(survey_list["Post Code"] == "DH6 1JD"),
"DH6 1JB",
survey_list["Post Code"]
)
return survey_list
@staticmethod
@ -2343,6 +2473,18 @@ class DataLoader:
]
return survey_list
@staticmethod
def correct_ha42_survey_list(survey_list):
# original asset list has nothing in the street
survey_list["Street / Block Name"] = survey_list["Street / Block Name"].str.replace(
"Turnstone Terrace", ""
)
survey_list["Street / Block Name"] = survey_list["Street / Block Name"].str.replace(
"Pegasus place", ""
)
return survey_list
@staticmethod
def levenstein_match(matching_string, df):
match_to = df["matching_address"].tolist()
@ -2926,7 +3068,7 @@ class DataLoader:
"eco4 subject to ciga": "eco4 (subject to ciga)",
"eco4 (subject to archetype/ciga)": "eco4 (subject to ciga) (subject to archetype)",
"eco4( subject to ciga/archetype)": "eco4 (subject to ciga) (subject to archetype)",
"eco4 (subject to ciga/ archetype)": "eco4 (subject to ciga) (subject to archetype)"
"eco4 (subject to ciga/ archetype)": "eco4 (subject to ciga) (subject to archetype)",
}
ha_facts_and_figures = []
@ -3189,6 +3331,9 @@ def get_property_type_and_built_form(property_meta, ha_name):
elif ha_name == "HA7":
property_type = PROPERTY_TYPE_LOOKUP[ha_name]["property_type"].get(property_meta["Archetype"])
built_form = PROPERTY_TYPE_LOOKUP[ha_name]["built_form"].get(property_meta["Property Type"])
elif ha_name == "HA8":
property_type = PROPERTY_TYPE_LOOKUP[ha_name].get(property_meta["Property Type"].strip())
built_form = None
elif ha_name == "HA9":
property_description = property_meta["Asset Type"].strip().lower()
if "house" in property_description:
@ -3204,6 +3349,9 @@ def get_property_type_and_built_form(property_meta, ha_name):
return "Maisonette", None
return None, None
elif ha_name == "HA11":
property_type = PROPERTY_TYPE_LOOKUP[ha_name].get(property_meta["Property Type"].strip())
built_form = None
elif ha_name == "HA12":
property_type = PROPERTY_TYPE_LOOKUP[ha_name].get(property_meta["Asset_Type1"].strip())
built_form = None
@ -3237,6 +3385,21 @@ def get_property_type_and_built_form(property_meta, ha_name):
elif ha_name == "HA19":
property_type = property_meta["Dwelling Type"]
built_form = None
elif ha_name == "HA21":
property_description = property_meta["Property Type"].strip().lower()
if "house" in property_description:
return "House", None
if "flat" in property_description:
return "Flat", None
if "bungalow" in property_description:
return "Bungalow", None
if "maisonette" in property_description:
return "Maisonette", None
return None, None
elif ha_name == "HA24":
property_type = PROPERTY_TYPE_LOOKUP[ha_name].get(property_meta["Property Type"].strip())
built_form = None
@ -3277,6 +3440,9 @@ def get_property_type_and_built_form(property_meta, ha_name):
elif ha_name == "HA35":
property_type = PROPERTY_TYPE_LOOKUP[ha_name].get(property_meta["Property Type Grouping"].strip())
built_form = None
elif ha_name == "HA37":
property_type = PROPERTY_TYPE_LOOKUP[ha_name].get(property_meta["PROPERTY TYPE"].strip())
built_form = None
elif ha_name == "HA39":
property_type_config = PROPERTY_TYPE_LOOKUP[ha_name].get(property_meta["ConstructionStyle"], {})
property_type = property_type_config.get("property_type", None)
@ -3291,6 +3457,9 @@ def get_property_type_and_built_form(property_meta, ha_name):
elif ha_name == "HA41":
property_type = PROPERTY_TYPE_LOOKUP[ha_name].get(property_meta["Archetype"].strip())
built_form = None
elif ha_name == "HA42":
property_type = PROPERTY_TYPE_LOOKUP[ha_name].get(property_meta["Dwelling use/type"].strip())
built_form = None
elif ha_name == "HA48":
property_type = PROPERTY_TYPE_LOOKUP[ha_name].get(property_meta["Property Type"].strip())
built_form = None
@ -5515,10 +5684,9 @@ def forecast_remaining_sales(loader):
def fml_data_pull(loader):
has_bruh = [
"HA7", "HA14", "HA25", "HA39", "HA16", "HA28", "HA13",
# Updated get_property_type_and_built_form, still needs running
"HA50", "HA24", "HA15", "HA32", "HA28", "HA6", "HA1", "HA107", "HA41", "HA48", "HA2", "HA63", "HA12",
"HA117", "HA35", "HA34", "HA56", "HA19", "HA18", "HA9", "HA27", "HA30", "HA31", "HA54", "HA49",
# todo
'HA8', 'HA11', 'HA21', 'HA37', 'HA42',
]
# Can't pull from EPC database because it's based in Scotland
@ -5613,10 +5781,9 @@ def fml_analysis(loader):
assumed_ciga_pass_rate = 0.731
has_bruh = [
"HA7", "HA14", "HA25", "HA39", "HA16", "HA28", "HA13",
# Updated get_property_type_and_built_form, still needs running
"HA50", "HA24", "HA15", "HA32", "HA28", "HA6", "HA1", "HA107", "HA41", "HA48", "HA2", "HA63", "HA12",
"HA117", "HA35", "HA34", "HA56", "HA19", "HA18", "HA9", "HA27", "HA30", "HA31", "HA54", "HA49",
# todo
'HA8', 'HA11', 'HA21', 'HA37', 'HA42',
]
no_ciga_cavity_descriptions = [
@ -5639,7 +5806,7 @@ def fml_analysis(loader):
"HA39", "HA14", "HA24", "HA15", "HA32", "HA28", "HA6", "HA1", "HA7",
"HA16", "HA107", "HA25", "HA50", "HA41", "HA48", "HA2", "HA63", "HA12",
"HA117", "HA13", "HA35", "HA34", "HA56", "HA19", "HA18", "HA9", "HA27",
"HA30", "HA31", "HA54", "HAXX", "HA49", "HAXXX"
"HA30", "HA31", "HA54", "HAXX", "HA49", "HAXXX",
]
values = [
@ -5660,7 +5827,6 @@ def fml_analysis(loader):
].copy()
original_remaining = original_figures["ECO4 remaining"].values[0]
original_gbis_remaining = original_figures["GBIS remaining"].values[0]
postcode_list_remaining = remaining_eligible_mapping[ha_name]
# Read in the epc data
asset_list = loader.data[ha_name]["asset_list"].copy()
@ -5992,10 +6158,10 @@ def fml_analysis(loader):
"HA Name": ha_name,
"Original ECO4 Estimate - Remaining": original_remaining,
"Original GGBIS Estimate - Remaining": original_gbis_remaining,
"Postcode List - Remaining": postcode_list_remaining,
# "Postcode List - Remaining": postcode_list_remaining,
# "Of which sold": sales_since_nov,
"Of which ECO4 Eligible - Remaining": int(total_eco4_expectation),
"Of which GBIS Eligibile - Remaining": int(total_gbis_expectation),
"EPC verified ECO4 Eligible - Remaining": int(total_eco4_expectation),
"EPC verified GBIS Eligibile - Remaining": int(total_gbis_expectation),
}
)
@ -6036,7 +6202,8 @@ def app():
"HA27", "HA28", "HA30", "HA31", "HA32", "HA34", "HA35", "HA39", "HA41", "HA48", "HA49", "HA50", "HA54", "HA56",
"HA63", "HA107", "HA117",
# Added as of March 17th
"HA8", "HA11", "HA21",
"HA8", "HA11", "HA21", "HA37", "HA42",
"HA44",
# New HAS
"HAXX", "HAXXX",
]