mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
Added property type and built form to asset list
This commit is contained in:
parent
1102d5383e
commit
5a65032bfe
4 changed files with 37 additions and 4 deletions
2
.idea/Model.iml
generated
2
.idea/Model.iml
generated
|
|
@ -7,7 +7,7 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/open_uprn" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/open_uprn" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/recommendations" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/recommendations" isTestSource="false" />
|
||||||
</content>
|
</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" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PyNamespacePackagesService">
|
<component name="PyNamespacePackagesService">
|
||||||
|
|
|
||||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
|
@ -3,7 +3,7 @@
|
||||||
<component name="Black">
|
<component name="Black">
|
||||||
<option name="sdkName" value="Python 3.10 (backend)" />
|
<option name="sdkName" value="Python 3.10 (backend)" />
|
||||||
</component>
|
</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">
|
<component name="PythonCompatibilityInspectionAdvertiser">
|
||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
</component>
|
</component>
|
||||||
|
|
|
||||||
|
|
@ -638,7 +638,7 @@ async def build_mds(body: PlanTriggerRequest):
|
||||||
)
|
)
|
||||||
|
|
||||||
input_properties = []
|
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
|
# We validate each record in the file. If the record is NOT valid, we need to handle this accordingly
|
||||||
uprn = config.get("uprn", None)
|
uprn = config.get("uprn", None)
|
||||||
if uprn:
|
if uprn:
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,33 @@ def extract_mds_measures(config):
|
||||||
return measures
|
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():
|
def app():
|
||||||
"""
|
"""
|
||||||
Create the initial asset list for the E.ON pilot
|
Create the initial asset list for the E.ON pilot
|
||||||
|
|
@ -174,6 +201,8 @@ def app():
|
||||||
# import pandas as pd
|
# import pandas as pd
|
||||||
# asset_list_with_uprn_df = pd.DataFrame(asset_list_with_uprn)
|
# 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)
|
# 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
|
# Store the asset list and create the portfolio payload
|
||||||
asset_list_with_uprn_df = pd.DataFrame(asset_list_with_uprn)
|
asset_list_with_uprn_df = pd.DataFrame(asset_list_with_uprn)
|
||||||
|
|
@ -191,13 +220,17 @@ def app():
|
||||||
|
|
||||||
measures = extract_mds_measures(config)
|
measures = extract_mds_measures(config)
|
||||||
|
|
||||||
|
# Get the property type
|
||||||
|
pt = parse_property_type(config)
|
||||||
|
|
||||||
finalised_asset_list.append(
|
finalised_asset_list.append(
|
||||||
{
|
{
|
||||||
"address": config["Address"],
|
"address": config["Address"],
|
||||||
"postcode": config["Postcode"],
|
"postcode": config["Postcode"],
|
||||||
"uprn": asset_config["uprn"].values[0],
|
"uprn": asset_config["uprn"].values[0],
|
||||||
"n_bedrooms": config["No Bedrooms"],
|
"n_bedrooms": config["No Bedrooms"],
|
||||||
"measures": measures
|
"measures": measures,
|
||||||
|
**pt
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
finalised_asset_list = pd.DataFrame(finalised_asset_list)
|
finalised_asset_list = pd.DataFrame(finalised_asset_list)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue