From 4a89b1f40920fee0b4784886c6fa07b8622a43f1 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Fri, 23 Jun 2023 16:06:12 +0100 Subject: [PATCH] moved year built --- model_data/Property.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/model_data/Property.py b/model_data/Property.py index bf128e6b..8f542f67 100644 --- a/model_data/Property.py +++ b/model_data/Property.py @@ -37,6 +37,7 @@ class Property(BaseUtility): self.data = data self.full_sap_epc = None self.in_conservation_area = None + self.year_built = None if epc_client: self.epc_client = epc_client @@ -145,14 +146,16 @@ class Property(BaseUtility): """ if self.full_sap_epc: - return pd.to_datetime(self.full_sap_epc["lodgement-date"]).year + self.year_built = pd.to_datetime(self.full_sap_epc["lodgement-date"]).year + return if self.data["construction-age-band"] not in self.DATA_ANOMALY_MATCHES: # Take the lower limit. If we're pessimistic about the age of the property, that at least means we have # more options for recommendations if that age falls before the year that insulation in walls became # common practice band = [int(x) for x in re.findall(r'\b\d{4}\b', self.data["construction-age-band"])] - return band[0] + self.year_built = band[0] + return # We don't know when the property was built - return None + self.year_built = None