major refactor of handling of epc data and starting to set up extract_attributes

This commit is contained in:
Khalim Conn-Kowlessar 2025-02-20 08:45:15 +00:00
parent 37cc43adb1
commit ecc9d99540
2 changed files with 22 additions and 18 deletions

View file

@ -226,7 +226,14 @@ class AssetList:
"energy-consumption-current": "epc_heat_demand", "energy-consumption-current": "epc_heat_demand",
} }
FIND_EPC_DATA_NAMES = { FIND_EPC_DATA_NAMES = {
"heating_text": "epc_estiamted_heating_kwh",
"hot_water_text": "epc_estimated_hotwater_kwh",
'Assessors name': "epc_assessor_name",
"Assessor's Telephone": "epc_assessor_telephone",
"Assessor's Email": "epc_assessor_email",
"Accreditation scheme": "epc_assessor_accreditation",
"Assessors ID": "epc_assessor_id",
"Solar photovoltaics": "epc_solar_pv"
} }
DATETIME_REMAP = { DATETIME_REMAP = {
@ -265,7 +272,8 @@ class AssetList:
"Any further surveyor notes", 'Surveyors Name' "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__( def __init__(
self, self,
@ -615,9 +623,6 @@ class AssetList:
columns=self.rename_map columns=self.rename_map
) )
def create_lookup_mappings(self):
pass
def merge_data(self, df: pd.DataFrame): def merge_data(self, df: pd.DataFrame):
""" """
Used to insert data into the standardised asset list, based on the domna property id 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( self.standardised_asset_list = self.standardised_asset_list.merge(
df, how="left", on=self.DOMNA_PROPERTY_ID 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, ""])
)

View file

@ -522,25 +522,16 @@ def app():
) )
epc_df = epc_df.merge( epc_df = epc_df.merge(
find_my_epc_data[ 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),
asset_list.DOMNA_PROPERTY_ID, "heating_text", "hot_water_text", 'Assessors name',
"Assessor's Telephone", "Assessor's Email", "Accreditation scheme",
"Assessors ID", "Solar photovoltaics"
]
].rename(
columns={
"Solar photovoltaics": "Has Solar PV",
"heating_text": "Heating Estimated kWh",
"hot_water_text": "Hot Water Estimated kWh",
}
),
how="left", how="left",
on=asset_list.DOMNA_PROPERTY_ID on=asset_list.DOMNA_PROPERTY_ID
) )
asset_list.merge_data(epc_df) 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["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"]) asset_list = asset_list.drop(columns=["photo-supply"])