implemented lighting desctipion cleaning

This commit is contained in:
Khalim Conn-Kowlessar 2023-07-03 15:18:44 +01:00
parent d5e4baba05
commit e51a2142fd
2 changed files with 12 additions and 7 deletions

View file

@ -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()

View file

@ -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}