Added property type and built form to asset list

This commit is contained in:
Khalim Conn-Kowlessar 2024-05-21 10:31:17 +01:00
parent 1102d5383e
commit 5a65032bfe
4 changed files with 37 additions and 4 deletions

2
.idea/Model.iml generated
View file

@ -7,7 +7,7 @@
<sourceFolder url="file://$MODULE_DIR$/open_uprn" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/recommendations" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="Python 3.10 (backend)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.10 (model_data)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyNamespacePackagesService">

2
.idea/misc.xml generated
View file

@ -3,7 +3,7 @@
<component name="Black">
<option name="sdkName" value="Python 3.10 (backend)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (backend)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (model_data)" project-jdk-type="Python SDK" />
<component name="PythonCompatibilityInspectionAdvertiser">
<option name="version" value="3" />
</component>

View file

@ -638,7 +638,7 @@ async def build_mds(body: PlanTriggerRequest):
)
input_properties = []
for property_id, config in tqdm(enumerate(plan_input)):
for property_id, config in tqdm(enumerate(plan_input), total=len(plan_input)):
# We validate each record in the file. If the record is NOT valid, we need to handle this accordingly
uprn = config.get("uprn", None)
if uprn:

View file

@ -114,6 +114,33 @@ def extract_mds_measures(config):
return measures
def parse_property_type(config):
# This should come from the ordnance survey api eventually
# array(['Detached', 'Semi-detached', 'Bungalow', 'Mid Terrace',
# 'End Terrace', 'Top Flat', 'Mid Flat',
# 'Low rise flat (1-2 storey)', nan], dtype=object)
if config["Address"] == "Flat Central Garage":
return {"property_type": "Bungalow", "built_form": "Mid-Terrace"}
if pd.isnull(config["Property Type"]):
return {"property_type": None, "built_form": None}
lookup = {
"Detached": {"property_type": "House", "built_form": "Detached"},
"Semi-detached": {"property_type": "House", "built_form": "Semi-detached"},
"Bungalow": {"property_type": "Bungalow", "built_form": "Detached"},
"Mid Terrace": {"property_type": "House", "built_form": "Mid Terrace"},
"End Terrace": {"property_type": "House", "built_form": "End Terrace"},
"Top Flat": {"property_type": "Flat", "built_form": None},
"Mid Flat": {"property_type": "Flat", "built_form": None},
"Low rise flat (1-2 storey)": {"property_type": "Flat", "built_form": None},
}
return lookup[config["Property Type"]]
def app():
"""
Create the initial asset list for the E.ON pilot
@ -174,6 +201,8 @@ def app():
# import pandas as pd
# asset_list_with_uprn_df = pd.DataFrame(asset_list_with_uprn)
# asset_list_with_uprn_df.to_csv("eon_asset_list_with_uprn.csv", index=False)
# Read in
# asset_list_with_uprn = pd.read_csv("eon_asset_list_with_uprn.csv").to_dict(orient="records")
# Store the asset list and create the portfolio payload
asset_list_with_uprn_df = pd.DataFrame(asset_list_with_uprn)
@ -191,13 +220,17 @@ def app():
measures = extract_mds_measures(config)
# Get the property type
pt = parse_property_type(config)
finalised_asset_list.append(
{
"address": config["Address"],
"postcode": config["Postcode"],
"uprn": asset_config["uprn"].values[0],
"n_bedrooms": config["No Bedrooms"],
"measures": measures
"measures": measures,
**pt
}
)
finalised_asset_list = pd.DataFrame(finalised_asset_list)