mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
working on new forecast methodology
This commit is contained in:
parent
8b8e2bf902
commit
9e679bd3fd
1 changed files with 73 additions and 8 deletions
|
|
@ -2728,15 +2728,22 @@ def forecast_remaining_sales(loader):
|
|||
# Produce the final output
|
||||
december_figures = loader.december_figures.copy()
|
||||
december_figures = december_figures.fillna(0)
|
||||
# If we have negative remaining, it means that actually sold more gbis than they initially thought so we set
|
||||
# remaining to 0
|
||||
december_figures["ECO4 remaining"] = np.where(
|
||||
december_figures["ECO4 remaining"] < 0, 0, december_figures["ECO4 remaining"]
|
||||
)
|
||||
december_figures["GBIS remaining"] = np.where(
|
||||
december_figures["GBIS remaining"] < 0, 0, december_figures["GBIS remaining"]
|
||||
)
|
||||
|
||||
results = []
|
||||
for ha_name, input_data in loader.data.items():
|
||||
# Original warmfront figures
|
||||
# Original warmfront figures - ECO4
|
||||
original_warmfront_estimates = december_figures[december_figures["HA Name"] == ha_name]
|
||||
|
||||
original_warmfront_eco4 = original_warmfront_estimates["ECO4"].values[0]
|
||||
original_warmfront_remaining_eco4 = original_warmfront_estimates["ECO4 remaining"].values[0]
|
||||
original_warmfront_gbis = original_warmfront_estimates["GBIS"].values[0]
|
||||
original_warmfront_remaining_gbis = original_warmfront_estimates["GBIS remaining"].values[0]
|
||||
|
||||
original_warmfront_eco4_revenue = (
|
||||
original_warmfront_remaining_eco4 * eco4_rate +
|
||||
|
|
@ -2744,21 +2751,79 @@ def forecast_remaining_sales(loader):
|
|||
)
|
||||
original_warmfront_remaining_eco4_revenue = original_warmfront_remaining_eco4 * eco4_rate
|
||||
|
||||
# Original warmfront figures - GBIS
|
||||
|
||||
original_warmfront_gbis = original_warmfront_estimates["GBIS"].values[0]
|
||||
original_warmfront_remaining_gbis = original_warmfront_estimates["GBIS remaining"].values[0]
|
||||
|
||||
original_warmfront_gbis_revenue = (
|
||||
original_warmfront_remaining_gbis * gbis_rate +
|
||||
(original_warmfront_gbis - original_warmfront_remaining_gbis) * old_gbis_rate
|
||||
)
|
||||
original_warmfront_remaining_gbis_revenue = original_warmfront_remaining_gbis * gbis_rate
|
||||
|
||||
# Asset list
|
||||
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"])]
|
||||
|
||||
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()
|
||||
|
||||
eco4_pre_ciga = eligiblity_counts[
|
||||
eligiblity_counts["ECO Eligibility"].isin(
|
||||
["eco4", "eco4 (subject to ciga)", "eco4 - passed ciga", "failed ciga"]
|
||||
)
|
||||
]["count"].sum()
|
||||
|
||||
eco4_pre_ciga_remaining = eligiblity_counts_remaining[
|
||||
eligiblity_counts["ECO Eligibility"].isin(
|
||||
["eco4", "eco4 (subject to ciga)", "eco4 - passed ciga", "failed ciga"]
|
||||
)
|
||||
]["count"].sum()
|
||||
|
||||
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
|
||||
|
||||
if has_ciga_check:
|
||||
eco4_post_ciga = eligiblity_counts[
|
||||
eligiblity_counts["ECO Eligibility"].isin(
|
||||
["eco4", "eco4 (subject to ciga)", "eco4 - passed ciga", "failed ciga"]
|
||||
)
|
||||
]["count"].sum()
|
||||
|
||||
results.append(
|
||||
{
|
||||
("", "", "HA Name"): ha_name,
|
||||
("Original Warmfront estimate", "Total - #", "ECO4 - November"): original_warmfront_eco4,
|
||||
("", "Remaining - #", ""): original_warmfront_remaining_eco4,
|
||||
("", "Total - £", ""): original_warmfront_eco4_revenue,
|
||||
("", "Remaining - £", ""): original_warmfront_remaining_eco4_revenue,
|
||||
("", "", "", "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,
|
||||
}
|
||||
)
|
||||
|
||||
results = pd.DataFrame(results)
|
||||
|
||||
|
||||
def app():
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue