mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
finished get_coordinates
This commit is contained in:
parent
d1675e8478
commit
6488000406
3 changed files with 15 additions and 13 deletions
|
|
@ -9,9 +9,9 @@ class OpenUprnClient:
|
|||
|
||||
]
|
||||
|
||||
def __init__(self, path, urpns):
|
||||
def __init__(self, path, uprns):
|
||||
self.path = path
|
||||
self.urpns = [int(x) for x in urpns]
|
||||
self.uprns = [int(x) for x in uprns]
|
||||
self.data = None
|
||||
|
||||
def read(self):
|
||||
|
|
@ -22,6 +22,6 @@ class OpenUprnClient:
|
|||
logger.info("Reading in open uprn data")
|
||||
|
||||
df = pd.read_csv(self.path)
|
||||
df = df[df["UPRN"].isin(self.urpns)]
|
||||
df = df[df["UPRN"].isin(self.uprns)]
|
||||
|
||||
self.data = df
|
||||
|
|
|
|||
|
|
@ -47,9 +47,12 @@ class Property:
|
|||
the data
|
||||
"""
|
||||
|
||||
if not open_uprn_client.data:
|
||||
if open_uprn_client.data is None:
|
||||
raise ValueError("OpenUprnClient has not read data")
|
||||
|
||||
self.coordinates = open_uprn_client.data[
|
||||
open_uprn_client.data["UPRN"] == self.data["uprn"]
|
||||
].to_dict("records")[0]
|
||||
self.coordinates = (
|
||||
open_uprn_client.data[open_uprn_client.data["UPRN"] == int(self.data["uprn"])]
|
||||
.to_dict("records")[0]
|
||||
)
|
||||
|
||||
self.coordinates = {key.lower(): value for key, value in self.coordinates.items()}
|
||||
|
|
|
|||
|
|
@ -24,18 +24,18 @@ def handler():
|
|||
for p in input_properties:
|
||||
p.search_address_epc()
|
||||
|
||||
urpns = [p.data['uprn'] for p in input_properties]
|
||||
uprns = [p.data['uprn'] for p in input_properties]
|
||||
|
||||
open_urpn_client = OpenUprnClient(
|
||||
open_uprn_client = OpenUprnClient(
|
||||
path=os.path.abspath(
|
||||
os.path.dirname(__file__)
|
||||
) + "/model_data/local_data/osopenuprn_202306_csv/osopenuprn_202305.csv",
|
||||
urpns=urpns
|
||||
uprns=uprns
|
||||
)
|
||||
open_urpn_client.read()
|
||||
open_uprn_client.read()
|
||||
|
||||
for p in input_properties:
|
||||
p.get_coordinates(open_urpn_client)
|
||||
p.get_coordinates(open_uprn_client)
|
||||
|
||||
local_authorities = {p.data['local-authority'] for p in input_properties}
|
||||
|
||||
|
|
@ -124,7 +124,6 @@ def handler():
|
|||
|
||||
from dbfread import DBF
|
||||
|
||||
import pandas as pd
|
||||
borehole_file = os.path.abspath(os.path.dirname(__file__)) + "/model_data/local_data/borehole/borehole.dbf"
|
||||
table = DBF(borehole_file)
|
||||
borehole_data = [x for x in tqdm(table, total=len(table))]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue