diff --git a/etl/customers/stonewater/Wave 3 Preparation.py b/etl/customers/stonewater/Wave 3 Preparation.py index 5b1e2f91..d2110de8 100644 --- a/etl/customers/stonewater/Wave 3 Preparation.py +++ b/etl/customers/stonewater/Wave 3 Preparation.py @@ -1777,8 +1777,9 @@ def propsed_wave_3_sample(): "2 - same archetype", region_assets["Confidence Tier"] ) - region_assets["Current EPC Band"] = region_assets["Current EPC Band"].fillna( - region_assets["Current EPC Band_method2"].astype(str), + region_assets["Current EPC Band"] = np.where( + pd.isnull(region_assets["Current EPC Band"]) & pd.notnull(region_assets["Current EPC Band_method2"]), + region_assets["Current EPC Band_method2"], region_assets["Current EPC Band"] ) region_assets = region_assets.drop(columns=["Current EPC Band_method2"]) @@ -1822,12 +1823,26 @@ def propsed_wave_3_sample(): final_missed_matches.append( { "Address ID": a_id, - "Confidence Tier": "5 - no similar property, needs survey to confirm" + "Confidence Tier": "5 - no similar property, needs survey to confirm", + "Current EPC Band": "Unknown" } ) continue + # We take an average + expected_sap = surveyed_similar["Current SAP Rating"].mean() + expected_epc = sap_to_epc(expected_sap) + if expected_epc in ["C", "B", "A"]: + tier = "6 - EPC C or above" + else: + tier = "3 - similar property" - raise NotImplementedError("Implement me") + final_missed_matches.append( + { + "Address ID": a_id, + "Confidence Tier": tier, + "Current EPC Band": "Unknown" + } + ) final_missed_matches = pd.DataFrame(final_missed_matches) @@ -1841,14 +1856,13 @@ def propsed_wave_3_sample(): region_assets["Confidence Tier"] = region_assets["Confidence Tier"].fillna( region_assets["Confidence Tier_method3"] ) + region_assets["Current EPC Band"] = np.where( + pd.isnull(region_assets["Current EPC Band"]), + region_assets["Current EPC Band_method3"], region_assets["Current EPC Band"] + ) region_assets = region_assets.drop(columns=["Confidence Tier_method3"]) - region_assets["Current EPC Band"] = np.where( - region_assets["Confidence Tier"] == "5 - no similar property, needs survey to confirm", - "Unknown", region_assets["Current EPC Band"] - ) - if pd.isnull(region_assets["Current EPC Band"]).sum(): raise Exception("Something went wrong")