diff --git a/etl/customers/stonewater/Wave 3 Preparation.py b/etl/customers/stonewater/Wave 3 Preparation.py index f4195592..4a841f61 100644 --- a/etl/customers/stonewater/Wave 3 Preparation.py +++ b/etl/customers/stonewater/Wave 3 Preparation.py @@ -2126,8 +2126,16 @@ def propsed_wave_3_sample(): ) expected_epc = sap_to_epc(expected_sap) + archetype_data = archetype_data.sort_values("distance_meters", ascending=True) + # We take the features of the closest matching property - closest_match = archetype_data.sort_values("distance_meters", ascending=True).iloc[0] + closest_match = archetype_data.iloc[0] + + # Set the package ref + if expected_epc in ["C", "B", "A"]: + package_ref = None + else: + package_ref = archetype_data["Package Ref"].dropna().values[0] region_surveyed.append( { @@ -2141,7 +2149,7 @@ def propsed_wave_3_sample(): 'Survey: Primary Heating System': closest_match["Survey: Primary Heating System"], "Survey: Matching Address ID": closest_match["Address ID"], 'Distance to Closest Match (m)': closest_match["distance_meters"], - "Package Ref": closest_match["Package Ref"], + "Package Ref": package_ref, "Match Type": match_type } )