mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Adding in eligible properties left estimation
This commit is contained in:
parent
9e679bd3fd
commit
a81f1f2520
1 changed files with 69 additions and 32 deletions
|
|
@ -2613,7 +2613,7 @@ def forecast_remaining_sales(loader):
|
|||
converted_ciga_jobs["# Ciga dependent at installation"].sum()
|
||||
)
|
||||
|
||||
# 2) Calculate the conversion rate from CIGA dependent ciga passed
|
||||
# 2) Calculate the conversion rate from CIGA dependent to ciga passed
|
||||
ciga_passrates = []
|
||||
for ha_name, input_data in loader.data.items():
|
||||
|
||||
|
|
@ -2651,7 +2651,7 @@ def forecast_remaining_sales(loader):
|
|||
|
||||
ciga_passrates = pd.DataFrame(ciga_passrates)
|
||||
|
||||
median_ciga_pass_to_install = ciga_passrates["# CIGA passed"].sum() / ciga_passrates["# CIGA dependent"].sum()
|
||||
median_ciga_success_rate = ciga_passrates["# CIGA passed"].sum() / ciga_passrates["# CIGA dependent"].sum()
|
||||
|
||||
# 3) Calculate the conversion rate of an ECO4 and a GBISjob, that doesn't need ciga, to install
|
||||
eco4_ciga_independent_passrates = []
|
||||
|
|
@ -2762,16 +2762,20 @@ def forecast_remaining_sales(loader):
|
|||
)
|
||||
original_warmfront_remaining_gbis_revenue = original_warmfront_remaining_gbis * gbis_rate
|
||||
|
||||
# Asset list
|
||||
# Asset list - ECO4
|
||||
asset_list = input_data["asset_list"].copy()
|
||||
survey_list = input_data["survey_list"].copy()
|
||||
|
||||
asset_list_remaining = asset_list.merge(
|
||||
survey_list[["asset_list_row_id", "installation_status"]],
|
||||
how="left",
|
||||
on="asset_list_row_id"
|
||||
)
|
||||
asset_list_remaining = asset_list_remaining[pd.isnull(asset_list_remaining["installation_status"])]
|
||||
if survey_list.empty:
|
||||
asset_list_remaining = asset_list.copy()
|
||||
else:
|
||||
asset_list_remaining = asset_list.merge(
|
||||
survey_list[["asset_list_row_id", "installation_status"]],
|
||||
how="left",
|
||||
on="asset_list_row_id"
|
||||
)
|
||||
asset_list_remaining = asset_list_remaining[pd.isnull(asset_list_remaining["installation_status"])]
|
||||
asset_list_remaining = asset_list_remaining.drop(columns=["installation_status"])
|
||||
|
||||
eligiblity_counts = pd.DataFrame(asset_list["ECO Eligibility"].value_counts()).reset_index()
|
||||
eligiblity_counts_remaining = pd.DataFrame(asset_list_remaining["ECO Eligibility"].value_counts()).reset_index()
|
||||
|
|
@ -2791,36 +2795,69 @@ def forecast_remaining_sales(loader):
|
|||
eco4_pre_ciga_revenue = eco4_pre_ciga * eco4_rate
|
||||
eco4_pre_ciga_remaining_revenue = eco4_pre_ciga_remaining * eco4_rate
|
||||
|
||||
# We check if the property has done a CIGA check
|
||||
has_ciga_check = not input_data["ciga_list"].empty
|
||||
# Total Eligible - this is what passed ciga checks + strict. If we don't have what passed CIGA, we estimate
|
||||
# We check if the HA has done a CIGA check. Also, if we have assets dormant at CIGA, we estimate what will
|
||||
# convert
|
||||
# We estimate a conversion for anything left post CIGA
|
||||
ha_ciga_conversion = ciga_passrates[ciga_passrates["Ha Name"] == ha_name]
|
||||
if not ha_ciga_conversion.empty:
|
||||
ha_ciga_conversion_rate = (
|
||||
ha_ciga_conversion["# CIGA passed"].values[0] / ha_ciga_conversion["# CIGA dependent"].values[0]
|
||||
)
|
||||
else:
|
||||
ha_ciga_conversion_rate = (
|
||||
median_ciga_success_rate if median_ciga_success_rate <= median_ciga_success_rate else
|
||||
median_ciga_success_rate
|
||||
)
|
||||
|
||||
remaining_needing_ciga_check = eligiblity_counts[
|
||||
eligiblity_counts["ECO Eligibility"] == "eco4 (subject to ciga)"
|
||||
]["count"].sum()
|
||||
|
||||
has_ciga_check = not input_data["ciga_list"].empty
|
||||
if has_ciga_check:
|
||||
eco4_post_ciga = eligiblity_counts[
|
||||
eligiblity_counts["ECO Eligibility"].isin(
|
||||
["eco4", "eco4 (subject to ciga)", "eco4 - passed ciga", "failed ciga"]
|
||||
["eco4", "eco4 - passed ciga", "failed ciga"]
|
||||
)
|
||||
]["count"].sum()
|
||||
|
||||
results.append(
|
||||
{
|
||||
("", "", "", "HA Name"): ha_name,
|
||||
# ECO4 - original warmfront figures
|
||||
("", "Original Warmfront estimate", "Total - #", "ECO4 - November"): original_warmfront_eco4,
|
||||
("ECO4", "", "Remaining - #", ""): original_warmfront_remaining_eco4,
|
||||
("ECO4", "", "Total - £", ""): original_warmfront_eco4_revenue,
|
||||
("ECO4", "", "Remaining - £", ""): original_warmfront_remaining_eco4_revenue,
|
||||
# GBIS - original warmfront figures
|
||||
("", "Original Warmfront estimate", "Total - #", "GBIS - November"): original_warmfront_gbis,
|
||||
("GBIS", "", "Remaining - #", ""): original_warmfront_gbis,
|
||||
("GBIS", "", "Total - £", ""): original_warmfront_gbis_revenue,
|
||||
("GBIS", "", "Remaining - £", ""): original_warmfront_remaining_gbis_revenue,
|
||||
# ECO4 - asset list
|
||||
("", "Warmfront post code list", "Total #", "ECO4 total (pre-ciga)"): eco4_pre_ciga,
|
||||
("ECO4", "", "Remaining - #", ""): eco4_pre_ciga_remaining,
|
||||
("ECO4", "", "Total - £", ""): eco4_pre_ciga_revenue,
|
||||
("ECO4", "", "Remaining - £", ""): eco4_pre_ciga_remaining_revenue,
|
||||
}
|
||||
)
|
||||
if remaining_needing_ciga_check > 0:
|
||||
# We update the eco4 post ciga with the converted remaining
|
||||
eco4_post_ciga += np.round(remaining_needing_ciga_check * ha_ciga_conversion_rate)
|
||||
else:
|
||||
eco4_post_ciga = eligiblity_counts[
|
||||
eligiblity_counts["ECO Eligibility"] == "eco4"
|
||||
]["count"].sum() + np.round(remaining_needing_ciga_check * ha_ciga_conversion_rate)
|
||||
|
||||
eco4_post_ciga = int(eco4_post_ciga)
|
||||
|
||||
to_append = {
|
||||
("", "", "", "HA Name"): ha_name,
|
||||
# ECO4 - original warmfront figures
|
||||
("", "Original Warmfront estimate", "Total - #", "ECO4 - November"): original_warmfront_eco4,
|
||||
("ECO4 original", "", "Remaining - #", ""): original_warmfront_remaining_eco4,
|
||||
("ECO4 original", "", "Total - £", ""): original_warmfront_eco4_revenue,
|
||||
("ECO4 original", "", "Remaining - £", ""): original_warmfront_remaining_eco4_revenue,
|
||||
# GBIS - original warmfront figures
|
||||
("", "Original Warmfront estimate", "Total - #", "GBIS - November"): original_warmfront_gbis,
|
||||
("GBIS original", "", "Remaining - #", ""): original_warmfront_gbis,
|
||||
("GBIS original", "", "Total - £", ""): original_warmfront_gbis_revenue,
|
||||
("GBIS original", "", "Remaining - £", ""): original_warmfront_remaining_gbis_revenue,
|
||||
# ECO4 - asset list, pre-ciga
|
||||
("", "Warmfront post code list", "Total #", "ECO4 total (pre-ciga)"): eco4_pre_ciga,
|
||||
("ECO4 pre-ciga", "", "Remaining - #", ""): eco4_pre_ciga_remaining,
|
||||
("ECO4 pre-ciga", "", "Total - £", ""): eco4_pre_ciga_revenue,
|
||||
("ECO4 pre-ciga", "", "Remaining - £", ""): eco4_pre_ciga_remaining_revenue,
|
||||
# ECO4 - asset list, post ciga
|
||||
("ECO4 post-ciga", "", "Estimated total eligible - #", ""): eco4_post_ciga,
|
||||
}
|
||||
|
||||
# Make sure nothing is forgotten due to duplicate multi-index keys
|
||||
if len(to_append) != 14:
|
||||
raise ValueError("Something went wrong")
|
||||
|
||||
results.append(to_append)
|
||||
|
||||
results = pd.DataFrame(results)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue