From d2a74d5612439e3732553eb133129c2aaad9f5bc Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Fri, 23 May 2025 10:48:08 +0100 Subject: [PATCH] adding in a placeholder method which will assume that properties without an EPC, are going to be older properties --- backend/SearchEpc.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/SearchEpc.py b/backend/SearchEpc.py index 0010191a..1ee1f950 100644 --- a/backend/SearchEpc.py +++ b/backend/SearchEpc.py @@ -702,6 +702,18 @@ class SearchEpc: exclude_old=exclude_old ) + # Check if it's a new build EPC. A property that doesn't have an EPC is not going to be a new build + # so we avoid comparing it to new builds + # TODO - this is experimental + newer_age_bands = [ + "England and Wales: 1996-2002", "England and Wales: 2003-2006", "England and Wales: 2007-2011", + "England and Wales: 2012 onwards" + ] + + if (~epc_data["construction-age-band"].isin(newer_age_bands)).sum(): + # We have some older age bands, so we need to filter them out + epc_data = epc_data[~epc_data["construction-age-band"].isin(newer_age_bands)].copy() + # If we have missing lodgment date, we fill it with inspection-date epc_data["lodgement-datetime"] = epc_data["lodgement-datetime"].fillna(epc_data["inspection-date"]) # If we still have missing dates, we set it to the mean of the non NA dates