mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Handling property type for ha 107 and 39
This commit is contained in:
parent
ef27d6b164
commit
3cfb2002e4
1 changed files with 119 additions and 7 deletions
|
|
@ -125,11 +125,11 @@ class DataLoader:
|
|||
elif ha_name == "ha_39":
|
||||
# Create matching_address by concatenating add_1, add_2, add_3, add_4, add_5, post_code
|
||||
asset_list["matching_address"] = asset_list["add_1"].astype(str).str.lower().str.strip() + ", " + \
|
||||
asset_list["add_2"].str.lower().str.strip() + ", " + \
|
||||
asset_list["add_3"].str.lower().str.strip() + ", " + \
|
||||
asset_list["add_4"].str.lower().str.strip() + ", " + \
|
||||
asset_list["add_5"].str.lower().str.strip() + ", " + \
|
||||
asset_list["post_code"].str.lower().str.strip()
|
||||
asset_list["add_2"].astype(str).str.lower().str.strip() + ", " + \
|
||||
asset_list["add_3"].astype(str).str.lower().str.strip() + ", " + \
|
||||
asset_list["add_4"].astype(str).str.lower().str.strip() + ", " + \
|
||||
asset_list["add_5"].astype(str).str.lower().str.strip() + ", " + \
|
||||
asset_list["post_code"].astype(str).str.lower().str.strip()
|
||||
asset_list["matching_postcode"] = asset_list["post_code"].str.lower().str.strip()
|
||||
elif ha_name == "ha_107":
|
||||
# Create matching_address by concatenating House No, Street, Town, District, Postcode
|
||||
|
|
@ -520,10 +520,70 @@ def get_epc_data(
|
|||
'WARDEN FLAT': "Flat",
|
||||
'EXTRACARE SCHEME': "Flat",
|
||||
}
|
||||
|
||||
},
|
||||
"ha_14": {
|
||||
"property_type": {
|
||||
"House": "House",
|
||||
"Flat": "Flat",
|
||||
"Bungalow": "Bungalow",
|
||||
"Maisonette": "Maisonette",
|
||||
}
|
||||
},
|
||||
"ha_39": {
|
||||
"Semi house": {"property_type": "House", "built_form": "Semi-Detached"},
|
||||
"1st floor flat": {"property_type": "Flat", "built_form": None},
|
||||
"Mid terrace house": {"property_type": "House", "built_form": "Mid-Terrace"},
|
||||
"Ground floor flat": {"property_type": "Flat", "built_form": None},
|
||||
"End terrace house": {"property_type": "House", "built_form": "End-Terrace"},
|
||||
"Semi bungalow": {"property_type": "Bungalow", "built_form": "Semi-Detached"},
|
||||
"End terrace bungalow": {"property_type": "Bungalow", "built_form": "End-Terrace"},
|
||||
"2nd floor flat": {"property_type": "Flat", "built_form": None},
|
||||
"Mid terrace bungalow": {"property_type": "Bungalow", "built_form": "Mid-Terrace"},
|
||||
"3rd floor flat": {"property_type": "Flat", "built_form": None},
|
||||
"Detached bungalow": {"property_type": "Bungalow", "built_form": "Detached"},
|
||||
"Maisonette": {"property_type": "Maisonette", "built_form": None},
|
||||
"Detached house": {"property_type": "House", "built_form": "Detached"},
|
||||
"Lower ground floor flat": {"property_type": "Flat", "built_form": None},
|
||||
"Dormer bungalow": {"property_type": "Bungalow", "built_form": None},
|
||||
"Basement flat": {"property_type": "Flat", "built_form": None},
|
||||
"Cluster House": {"property_type": "House", "built_form": "Detached"},
|
||||
"2nd/3rd floor duplex flat": {"property_type": "Flat", "built_form": None},
|
||||
"Ground floor flat with study": {"property_type": "Flat", "built_form": None},
|
||||
"4th floor flat": {"property_type": "Flat", "built_form": None},
|
||||
"1st floor flat with study room": {"property_type": "Flat", "built_form": None},
|
||||
"2nd floor flat with study": {"property_type": "Flat", "built_form": None},
|
||||
},
|
||||
"ha_107": {
|
||||
"property_type": {
|
||||
"HOUSE": "House",
|
||||
"BUNGALOW": "Bungalow",
|
||||
"GRD FLOOR FLAT": "Flat",
|
||||
"FIRST FLOOR FLAT": "Flat",
|
||||
"SHELTERED BUNGALOW": "Bungalow",
|
||||
"MAISONETTE": "Maisonette",
|
||||
"SECOND FLOOR FLAT": "Flat",
|
||||
"SHELTERED FIRST FLR": "Flat",
|
||||
"SHELTERED GROUND FLR": "Flat",
|
||||
"GRD FLOOR BED SIT": "House"
|
||||
},
|
||||
"built_form": {
|
||||
"Semi Detached": "Semi-Detached",
|
||||
"Mid Terrace": "Mid-Terrace",
|
||||
"End Terrace": "End-Terrace",
|
||||
"Detached": "Detached",
|
||||
"Detatched": "Detached",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# TODO: Sort these
|
||||
# DwellingType
|
||||
# UNKNOWN 395
|
||||
# SHELTERED FIRST FLR 77
|
||||
# 62
|
||||
# ROOM 4
|
||||
# GRD FLOOR BED SIT 3
|
||||
|
||||
outputs = {}
|
||||
for ha_name, data_assets in loader.data.items():
|
||||
|
||||
|
|
@ -571,11 +631,63 @@ def get_epc_data(
|
|||
elif ha_name == "ha_6":
|
||||
property_type = property_type_lookup[ha_name]["property_type"][property_meta["Dwelling type"]]
|
||||
built_form = property_meta["built_form"]
|
||||
elif ha_name == "ha_14":
|
||||
if property_meta["Asset Type Description"] == "Block - Repair":
|
||||
# We try and deduce if it's a flat or house, depending on if it has "room" or "flats" in the address
|
||||
if "room" in property_meta["Address 1"].lower():
|
||||
property_type = "House"
|
||||
else:
|
||||
property_type = "Flat"
|
||||
|
||||
else:
|
||||
property_type = property_type_lookup[ha_name]["property_type"][
|
||||
property_meta["Asset Type Description"]
|
||||
]
|
||||
|
||||
built_form = None
|
||||
elif ha_name == "ha_39":
|
||||
|
||||
property_type_config = property_type_lookup[ha_name].get(property_meta["ConstructionStyle"], {})
|
||||
property_type = property_type_config.get("property_type", None)
|
||||
built_form = property_type_config.get("built_form", None)
|
||||
|
||||
if property_type is None:
|
||||
# We check for the presence of room or flat
|
||||
if "flat" in property_meta["matching_address"]:
|
||||
property_type = "Flat"
|
||||
else:
|
||||
property_type = "House"
|
||||
elif ha_name == "ha_107":
|
||||
|
||||
dwelling_style = property_meta["Dwelling Style"]
|
||||
if isinstance(dwelling_style, str):
|
||||
dwelling_style = dwelling_style.strip()
|
||||
|
||||
property_type = property_type_lookup[ha_name]["property_type"].get(property_meta["DwellingType"])
|
||||
built_form = property_type_lookup[ha_name]["built_form"].get(dwelling_style, None)
|
||||
|
||||
if property_type is None:
|
||||
if built_form in ["Semi-Detached", "Mid-Terrace", "End-Terrace", "Detached"]:
|
||||
property_type = "House"
|
||||
|
||||
if "flat" in property_meta["Wall Construction"].lower():
|
||||
property_type = "Flat"
|
||||
|
||||
if (property_meta["DwellingType"] == "UNKNOWN") & (property_meta["Dwelling Style"] == 0):
|
||||
# Hand a few specific cases
|
||||
property_type = "Bungalow"
|
||||
|
||||
if property_meta["Street"] == "School View":
|
||||
property_type = "Bungalow"
|
||||
|
||||
if property_type is None:
|
||||
blah
|
||||
|
||||
else:
|
||||
raise NotImplementedError("Implement me")
|
||||
|
||||
searcher = SearchEpc(
|
||||
address1=property_meta["HouseNo"],
|
||||
address1=str(property_meta["HouseNo"]),
|
||||
postcode=property_meta["matching_postcode"],
|
||||
auth_token=EPC_AUTH_TOKEN,
|
||||
os_api_key=None,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue