diff --git a/asset_list/AssetList.py b/asset_list/AssetList.py index 88425e6d..4ca4c2b8 100644 --- a/asset_list/AssetList.py +++ b/asset_list/AssetList.py @@ -226,7 +226,14 @@ class AssetList: "energy-consumption-current": "epc_heat_demand", } FIND_EPC_DATA_NAMES = { - + "heating_text": "epc_estiamted_heating_kwh", + "hot_water_text": "epc_estimated_hotwater_kwh", + 'Assessor’s name': "epc_assessor_name", + "Assessor's Telephone": "epc_assessor_telephone", + "Assessor's Email": "epc_assessor_email", + "Accreditation scheme": "epc_assessor_accreditation", + "Assessor’s ID": "epc_assessor_id", + "Solar photovoltaics": "epc_solar_pv" } DATETIME_REMAP = { @@ -265,7 +272,8 @@ class AssetList: "Any further surveyor notes", 'Surveyors Name' ] - #### Mapping for wall construction + # Attributes - these are columns that we produce, calcualted based on other pieces of data + ATTRIBUTE_HAS_SOLAR = "attribute_has_solar" def __init__( self, @@ -615,9 +623,6 @@ class AssetList: columns=self.rename_map ) - def create_lookup_mappings(self): - pass - def merge_data(self, df: pd.DataFrame): """ Used to insert data into the standardised asset list, based on the domna property id @@ -632,3 +637,11 @@ class AssetList: self.standardised_asset_list = self.standardised_asset_list.merge( df, how="left", on=self.DOMNA_PROPERTY_ID ) + + def extract_attributes(self): + # Used to extracty the typical attributes that we use to identify viable work + + self.standardised_asset_list[self.ATTRIBUTE_HAS_SOLAR] = ( + self.standardised_asset_list[self.FIND_EPC_DATA_NAMES["Solar photovoltaics"]] | + ~self.standardised_asset_list[self.EPC_API_DATA_NAMES["photo-supply"]].isin(["0.0", 0, None, ""]) + ) diff --git a/etl/route_march_data_pull/app.py b/etl/route_march_data_pull/app.py index 2e66c4aa..8b112ea2 100644 --- a/etl/route_march_data_pull/app.py +++ b/etl/route_march_data_pull/app.py @@ -522,25 +522,16 @@ def app(): ) epc_df = epc_df.merge( - find_my_epc_data[ - [ - asset_list.DOMNA_PROPERTY_ID, "heating_text", "hot_water_text", 'Assessor’s name', - "Assessor's Telephone", "Assessor's Email", "Accreditation scheme", - "Assessor’s ID", "Solar photovoltaics" - ] - ].rename( - columns={ - "Solar photovoltaics": "Has Solar PV", - "heating_text": "Heating Estimated kWh", - "hot_water_text": "Hot Water Estimated kWh", - } - ), + find_my_epc_data[[asset_list.DOMNA_PROPERTY_ID] + list(asset_list.FIND_EPC_DATA_NAMES.keys())] + .rename(columns=asset_list.FIND_EPC_DATA_NAMES), how="left", on=asset_list.DOMNA_PROPERTY_ID ) asset_list.merge_data(epc_df) + asset_list.extract_attributes() + asset_list["Has Solar PV"] = asset_list["Has Solar PV"] | ~asset_list["photo-supply"].isin(["0.0", 0, None, ""]) asset_list = asset_list.drop(columns=["photo-supply"])