From e51a2142fd65fb5961fe8a8185f22a9ce4179566 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 3 Jul 2023 15:18:44 +0100 Subject: [PATCH] implemented lighting desctipion cleaning --- model_data/EpcClean.py | 3 ++- model_data/epc_attributes/LightingAttributes.py | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/model_data/EpcClean.py b/model_data/EpcClean.py index 167d1640..3071e635 100644 --- a/model_data/EpcClean.py +++ b/model_data/EpcClean.py @@ -28,6 +28,7 @@ class EpcClean: "roof-description", "walls-description", "windows-description", + "lighting-description" ] def __init__(self, data: List[Dict[str, Any]]) -> None: @@ -60,7 +61,7 @@ class EpcClean: 'Excelent lighting efficiency' ] ) - ] + ].copy() aggs["low-energy-lighting"] = aggs["low-energy-lighting"].astype(float) averages = aggs.groupby("lighting-description")["low-energy-lighting"].mean().reset_index() diff --git a/model_data/epc_attributes/LightingAttributes.py b/model_data/epc_attributes/LightingAttributes.py index 49f39ef3..c3536f6e 100644 --- a/model_data/epc_attributes/LightingAttributes.py +++ b/model_data/epc_attributes/LightingAttributes.py @@ -7,23 +7,27 @@ class LightingAttributes: self.description: str = clean_description(description.lower()) self.averages = averages - def low_energy_proportions(self): + def process(self): description = self.description if 'no low energy lighting' in description: - return 0 + return {"low_energy_proportion": 0} if "all fixed outlets" in description: - return 1 + return {"low_energy_proportion": 1} if ('good lighting efficiency' in description) or ('excellent lighting efficiency' in description) or \ ('below average lighting efficiency' in description): - return self.averages[self.averages == description]["low-energy-lighting"].values[0] + return { + "low_energy_proportion": self.averages[self.averages == description]["low-energy-lighting"].values[0] + } match = re.search(r'\d+', description) if match: proportion = int(match.group()) / 100.0 - return proportion + return { + "low_energy_proportion": proportion + } - return 0 + return {"low_energy_proportion": 0}