mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
fetch old data construction age band if missing
This commit is contained in:
parent
eed5a0baa3
commit
beb45d451d
1 changed files with 17 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from collections import Counter
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
@ -334,8 +335,24 @@ class Property(Definitions):
|
||||||
raise ValueError("Property does not contain data")
|
raise ValueError("Property does not contain data")
|
||||||
|
|
||||||
self.construction_age_band = DataProcessor.clean_construction_age_band(self.data["construction-age-band"])
|
self.construction_age_band = DataProcessor.clean_construction_age_band(self.data["construction-age-band"])
|
||||||
|
if self.construction_age_band in self.DATA_ANOMALY_MATCHES:
|
||||||
|
if self.old_data:
|
||||||
|
# Take the most recent
|
||||||
|
max_datetime = max(
|
||||||
|
[x["lodgement-datetime"] for x in self.old_data if
|
||||||
|
x["construction-age-band"] not in self.DATA_ANOMALY_MATCHES]
|
||||||
|
)
|
||||||
|
most_recent = [x for x in self.old_data if x["lodgement-datetime"] == max_datetime]
|
||||||
|
|
||||||
|
self.construction_age_band = DataProcessor.clean_construction_age_band(
|
||||||
|
most_recent[0]["construction-age-band"]
|
||||||
|
)
|
||||||
|
|
||||||
self.age_band = england_wales_age_band_lookup.get(self.construction_age_band)
|
self.age_band = england_wales_age_band_lookup.get(self.construction_age_band)
|
||||||
|
|
||||||
|
if self.age_band is None:
|
||||||
|
raise ValueError("age_band is missing")
|
||||||
|
|
||||||
def set_spatial(self, spatial: pd.DataFrame):
|
def set_spatial(self, spatial: pd.DataFrame):
|
||||||
"""
|
"""
|
||||||
Sets whether the property is in a conservation area given the output of the ConservationAreaClient
|
Sets whether the property is in a conservation area given the output of the ConservationAreaClient
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue