Added HA8

This commit is contained in:
Khalim Conn-Kowlessar 2024-03-17 14:12:49 +00:00
parent 4e077053cd
commit a7ed3b84e5

View file

@ -517,6 +517,11 @@ class DataLoader:
asset_list["Address3"].astype(str).str.lower().str.strip() + ", " + \ asset_list["Address3"].astype(str).str.lower().str.strip() + ", " + \
asset_list["Postcode"].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() asset_list["matching_postcode"] = asset_list["Postcode"].astype(str).str.lower().str.strip()
elif ha_name == "HA8":
asset_list["matching_address"] = asset_list["AddressLine1"].astype(str).str.lower().str.strip() + ", " + \
asset_list["AddressLine2"].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 == "HA9": elif ha_name == "HA9":
asset_list["matching_address"] = asset_list["House Number"].astype(str).str.lower().str.strip() + ", " + \ 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() + ", " + \ asset_list["Address Line 1"].astype(str).str.lower().str.strip() + ", " + \
@ -2293,6 +2298,30 @@ class DataLoader:
def correct_ha49_survey_list(survey_list): def correct_ha49_survey_list(survey_list):
return survey_list return survey_list
@staticmethod
def correct_ha8_survey_list(survey_list):
# Split on / and take the first half
survey_list["Street / Block Name"] = survey_list["Street / Block Name"].str.split("/").str[0]
survey_list["Street / Block Name"] = survey_list["Street / Block Name"].str.replace(
"WESTONIA COURT HOUSE", "Westonia Court"
)
survey_list["Street / Block Name"] = survey_list["Street / Block Name"].str.replace(
"Hillesdon Avenue", "Hillesden Avenue"
)
survey_list["Street / Block Name"] = survey_list["Street / Block Name"].str.replace(
"Weston Street", "Western Street"
)
# Remove placeholder rows where postcode is missing
survey_list = survey_list[
~pd.isnull(survey_list["Post Code"])
]
return survey_list
@staticmethod @staticmethod
def levenstein_match(matching_string, df): def levenstein_match(matching_string, df):
match_to = df["matching_address"].tolist() match_to = df["matching_address"].tolist()
@ -5464,7 +5493,7 @@ def forecast_remaining_sales(loader):
def fml_data_pull(loader): def fml_data_pull(loader):
has_bruh = [ has_bruh = [
# "HA7", "HA14", "HA25", "HA39", "HA16", "HA28", "HA13", "HA7", "HA14", "HA25", "HA39", "HA16", "HA28", "HA13",
# Updated get_property_type_and_built_form, still needs running # Updated get_property_type_and_built_form, still needs running
"HA50", "HA24", "HA15", "HA32", "HA28", "HA6", "HA1", "HA107", "HA41", "HA48", "HA2", "HA63", "HA12", "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", "HA117", "HA35", "HA34", "HA56", "HA19", "HA18", "HA9", "HA27", "HA30", "HA31", "HA54", "HA49",
@ -5561,7 +5590,13 @@ def classify_loft(x):
def fml_analysis(loader): def fml_analysis(loader):
assumed_ciga_pass_rate = 0.731 assumed_ciga_pass_rate = 0.731
has_bruh = ["HA7", "HA14", "HA25", "HA39", "HA16", "HA1"] 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
]
no_ciga_cavity_descriptions = [ no_ciga_cavity_descriptions = [
"Cavity wall, as built, insulated (assumed)", "Cavity wall, as built, insulated (assumed)",
@ -5597,12 +5632,13 @@ def fml_analysis(loader):
results = [] results = []
wall_descriptions = [] wall_descriptions = []
for ha_name in has_bruh: for ha_name in tqdm(has_bruh):
original_figures = loader.december_figures[ original_figures = loader.december_figures[
loader.december_figures["HA Name"] == ha_name loader.december_figures["HA Name"] == ha_name
].copy() ].copy()
original_remaining = original_figures["ECO4 remaining"].values[0] 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] postcode_list_remaining = remaining_eligible_mapping[ha_name]
# Read in the epc data # Read in the epc data
@ -5669,7 +5705,54 @@ def fml_analysis(loader):
raise Exception("SOMETHING WENT WRONG") raise Exception("SOMETHING WENT WRONG")
if any(fuck_this["ECO Eligibility"].str.contains("subject to archetype")): if any(fuck_this["ECO Eligibility"].str.contains("subject to archetype")):
raise Exception("DO THE DAMN ARCHETYPE CHECK BRO") # We perform the archetype test. If the property is a house, we it needs to be detached, semi-detached
# or end terrace. If it's a bungalow, it must be attached
fuck_this["passes_archetype"] = None
fuck_this["passes_archetype"] = np.where(
(fuck_this["property-type"] == "House") &
(fuck_this["built-form"].isin(["Semi-Detached", "End-Terrace", "Detached"])),
True,
fuck_this["passes_archetype"]
)
fuck_this["passes_archetype"] = np.where(
(fuck_this["property-type"] == "Bungalow") &
(fuck_this["built-form"].isin(["Detached"])),
True,
fuck_this["passes_archetype"]
)
fuck_this["ECO Eligibility"] = np.where(
(fuck_this["ECO Eligibility"] == "eco4 (subject to ciga) (subject to archetype)") &
(fuck_this["passes_archetype"] == True),
"eco4 (subject to ciga)",
fuck_this["ECO Eligibility"]
)
# If failed the archetype check and needs a CIGA, it's not eligibile
fuck_this["ECO Eligibility"] = np.where(
(fuck_this["ECO Eligibility"] == "eco4 (subject to ciga) (subject to archetype)") &
(fuck_this["passes_archetype"] != True),
"not eligible",
fuck_this["ECO Eligibility"]
)
fuck_this["ECO Eligibility"] = np.where(
(fuck_this["ECO Eligibility"] == "eco4 (subject to archetype)") &
(fuck_this["passes_archetype"] == True),
"eco4",
fuck_this["ECO Eligibility"]
)
fuck_this["ECO Eligibility"] = np.where(
(fuck_this["ECO Eligibility"] == "eco4 (subject to archetype)") &
(fuck_this["passes_archetype"] != True),
"gbis",
fuck_this["ECO Eligibility"]
)
if any(fuck_this["ECO Eligibility"].str.contains("subject to archetype")):
raise Exception("DO THE DAMN ARCHETYPE CHECK BRO")
# clean roof insulation # clean roof insulation
fuck_this["roof_insulation_thickness"] = fuck_this["roof_insulation_thickness"].fillna("0") fuck_this["roof_insulation_thickness"] = fuck_this["roof_insulation_thickness"].fillna("0")
@ -5685,6 +5768,9 @@ def fml_analysis(loader):
fuck_this["roof_insulation_thickness"] = fuck_this[ fuck_this["roof_insulation_thickness"] = fuck_this[
"roof_insulation_thickness" "roof_insulation_thickness"
].str.replace("average", "150") ].str.replace("average", "150")
fuck_this["roof_insulation_thickness"] = fuck_this[
"roof_insulation_thickness"
].str.replace("above 150", "150")
fuck_this["roof_classiciation"] = fuck_this.apply(lambda x: classify_loft(x), axis=1) fuck_this["roof_classiciation"] = fuck_this.apply(lambda x: classify_loft(x), axis=1)
@ -5884,6 +5970,7 @@ def fml_analysis(loader):
{ {
"HA Name": ha_name, "HA Name": ha_name,
"Original ECO4 Estimate - Remaining": original_remaining, "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 sold": sales_since_nov,
"Of which ECO4 Eligible - Remaining": int(total_eco4_expectation), "Of which ECO4 Eligible - Remaining": int(total_eco4_expectation),
@ -5927,7 +6014,8 @@ def app():
"HA1", "HA2", "HA6", "HA7", "HA9", "HA12", "HA13", "HA14", "HA15", "HA16", "HA18", "HA19", "HA24", "HA25", "HA1", "HA2", "HA6", "HA7", "HA9", "HA12", "HA13", "HA14", "HA15", "HA16", "HA18", "HA19", "HA24", "HA25",
"HA27", "HA28", "HA30", "HA31", "HA32", "HA34", "HA35", "HA39", "HA41", "HA48", "HA49", "HA50", "HA54", "HA56", "HA27", "HA28", "HA30", "HA31", "HA32", "HA34", "HA35", "HA39", "HA41", "HA48", "HA49", "HA50", "HA54", "HA56",
"HA63", "HA107", "HA117", "HA63", "HA107", "HA117",
# Added as of March 17th
"HA8",
# New HAS # New HAS
"HAXX", "HAXXX", "HAXX", "HAXXX",
] ]