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}