handing facts and figures for ha28

This commit is contained in:
Khalim Conn-Kowlessar 2024-03-03 16:22:42 +00:00
parent 0909b811ee
commit 87c77e53c0

View file

@ -398,6 +398,8 @@ class DataLoader:
return "CIGA Checks" return "CIGA Checks"
elif "CIGA checks" in workbook.sheetnames: elif "CIGA checks" in workbook.sheetnames:
return "CIGA checks" return "CIGA checks"
elif "CIGA check" in workbook.sheetnames:
return "CIGA check"
else: else:
return "CIGA" return "CIGA"
@ -1318,14 +1320,16 @@ class DataLoader:
"ECO4 A/W": "ECO4", "ECO4 A/W": "ECO4",
"ECO4 GBIS (ECO+)": "GBIS", "ECO4 GBIS (ECO+)": "GBIS",
"ECO4 GBIS (ECO+) JJC UNDER 73m²": "GBIS", "ECO4 GBIS (ECO+) JJC UNDER 73m²": "GBIS",
"ECO4 AFFORDABLE WARMTH": "ECO4" "ECO4 AFFORDABLE WARMTH": "ECO4",
"Affordable Warmth": "ECO4"
} }
eco_eligibility_map = { eco_eligibility_map = {
"not eligble": "not eligible", "not eligble": "not eligible",
"eco 4(subject to ciga)": "eco4 (subject to ciga)", "eco 4(subject to ciga)": "eco4 (subject to ciga)",
"eco4 (subject to ciga/archetype check": "eco4 (subject to ciga)", "eco4 (subject to ciga/archetype check": "eco4 (subject to ciga)",
"eco4 (subject to archetype check)": "eco4" "eco4 (subject to archetype check)": "eco4",
"eco4 (subject to ciga/archetype)": "eco4 (subject to ciga)",
} }
ha_facts_and_figures = [] ha_facts_and_figures = []
@ -1384,46 +1388,56 @@ class DataLoader:
sales_report = {} sales_report = {}
if not survey_list.empty: if not survey_list.empty:
scheme_column = survey_list.columns[0] scheme_column = survey_list.columns[0]
# We clean up the survey list installation or cancelled
survey_list["installed_or_cancelled_clean"] = survey_list["INSTALLED OR CANCELLED"].str.lower()
# Remove all punctuation
survey_list["installed_or_cancelled_clean"] = survey_list["installed_or_cancelled_clean"].str.replace(
r'[^\w\s]', '', regex=True
)
# Remove double spaces
survey_list["installed_or_cancelled_clean"] = survey_list["installed_or_cancelled_clean"].str.replace(
r'\s+', ' ', regex=True
)
# Remove trailing spaces
survey_list["installed_or_cancelled_clean"] = survey_list["installed_or_cancelled_clean"].str.strip()
# Remap the values in the scheme column # Remap the values in the scheme column
survey_list[scheme_column] = survey_list[scheme_column].replace(scheme_map) survey_list[scheme_column] = survey_list[scheme_column].replace(scheme_map)
# We clean up the survey list installation or cancelled
if "INSTALLED OR CANCELLED" in survey_list.columns:
survey_list["installed_or_cancelled_clean"] = survey_list["INSTALLED OR CANCELLED"].str.lower()
# Remove all punctuation
survey_list["installed_or_cancelled_clean"] = survey_list[
"installed_or_cancelled_clean"].str.replace(
r'[^\w\s]', '', regex=True
)
# Remove double spaces
survey_list["installed_or_cancelled_clean"] = survey_list[
"installed_or_cancelled_clean"].str.replace(
r'\s+', ' ', regex=True
)
# Remove trailing spaces
survey_list["installed_or_cancelled_clean"] = survey_list[
"installed_or_cancelled_clean"].str.strip()
survey_list["installation_status"] = None survey_list["installation_status"] = None
survey_list["installation_status"] = np.where( survey_list["installation_status"] = np.where(
survey_list["installed_or_cancelled_clean"].isin(["installed", "installed see notes"]), survey_list["installed_or_cancelled_clean"].isin(["installed", "installed see notes"]),
"installed", "installed",
survey_list["installation_status"] survey_list["installation_status"]
) )
survey_list["installation_status"] = np.where( survey_list["installation_status"] = np.where(
survey_list["installed_or_cancelled_clean"].isin(["cancelled"]), survey_list["installed_or_cancelled_clean"].isin(["cancelled"]),
"cancelled", "cancelled",
survey_list["installation_status"] survey_list["installation_status"]
) )
# Find partial installations # Find partial installations
survey_list["installation_status"] = np.where( survey_list["installation_status"] = np.where(
survey_list["installed_or_cancelled_clean"].str.contains("still to be installed"), survey_list["installed_or_cancelled_clean"].str.contains("still to be installed"),
"partially installed", "partially installed",
survey_list["installation_status"] survey_list["installation_status"]
) )
# Find partial cancellations # Find partial cancellations
# TODO: We might have more indications of partial cancellations # TODO: We might have more indications of partial cancellations
survey_list["installation_status"] = np.where( survey_list["installation_status"] = np.where(
survey_list["installed_or_cancelled_clean"].isin(["loft cancelled"]), survey_list["installed_or_cancelled_clean"].isin(["loft cancelled"]),
"partially cancelled", "partially cancelled",
survey_list["installation_status"] survey_list["installation_status"]
) )
else:
# We have some examples, e.g. HA28, where we do not have the installed or cancelled column
survey_list["installation_status"] = np.where(
survey_list['INSTALL/ CANCELLATION DATE'].str.lower().str.contains("cancelled"),
"cancelled",
"installed",
)
# Finally, for other cases, we set the status to "in progress" # Finally, for other cases, we set the status to "in progress"
survey_list["installation_status"] = survey_list["installation_status"].fillna("in progress") survey_list["installation_status"] = survey_list["installation_status"].fillna("in progress")