From 0fafb03deebca4833680594b989b8362386257be Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 19 Nov 2024 22:06:51 +0000 Subject: [PATCH] tidying up code --- .../stonewater/Wave 3 Preparation.py | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/etl/customers/stonewater/Wave 3 Preparation.py b/etl/customers/stonewater/Wave 3 Preparation.py index 4a841f61..34ab778a 100644 --- a/etl/customers/stonewater/Wave 3 Preparation.py +++ b/etl/customers/stonewater/Wave 3 Preparation.py @@ -2366,10 +2366,8 @@ def propsed_wave_3_sample(): results = pd.concat(results) - results[ - pd.isnull(results["Package Ref"]) & (results["Current EPC Band"] == "D") - ]["Postal Region"] - results[resul] + if (pd.isnull(results["Package Ref"]) & (~results["Current EPC Band"].isin(["A", "B", "C"]))).sum(): + raise ValueError("Missing Package Refs") # Check if there are missings in current epc band, current sap rating or any of the survey attributes for c in ( @@ -2442,27 +2440,6 @@ def propsed_wave_3_sample(): ].sum() print("Total needing survey:", total_needing_survey) - # Look for postcodes that have no loss - unselected_streets = street_summary[ - ~street_summary["Selected"] - ]["Street and Region"].values - - postcode_summary = results[ - results["Street and Region"].isin(unselected_streets) - ].pivot_table( - index='Postcode', - columns='Confidence Tier', - aggfunc='size', - fill_value=0 - ).reset_index() - - postcode_summary["Gain"] = postcode_summary[gain_columns].sum(axis=1) - postcode_summary["Loss"] = postcode_summary[loss_columns].sum(axis=1) - - no_loss_postcodes = postcode_summary[postcode_summary["Loss"] == 0].sort_values("Gain", ascending=False) - total_bid_size = bid_size + no_loss_postcodes["Gain"].sum() - print(total_bid_size) - # Label final outputs # We create a summary of packages by street results["Package Ref"] = results["Package Ref"].fillna("Incomplete")