mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
39 lines
851 B
Python
39 lines
851 B
Python
import pandas as pd
|
|
from tqdm import tqdm
|
|
from backend.address2UPRN.main import get_uprn
|
|
|
|
# Enable tqdm for pandas
|
|
tqdm.pandas()
|
|
|
|
file_name = "forhousing.xlsx"
|
|
|
|
df = pd.read_excel(file_name)
|
|
|
|
|
|
def extract_uprn(row):
|
|
user_input = "Address"
|
|
postcode = "Postcode"
|
|
result = get_uprn(
|
|
row[user_input],
|
|
row[postcode],
|
|
return_address=True,
|
|
return_EPC=True,
|
|
return_score=True,
|
|
)
|
|
|
|
if result is None:
|
|
return pd.Series([None, None, None, None])
|
|
|
|
uprn, found_address, epc, score = result
|
|
return pd.Series([uprn, found_address, epc, score])
|
|
|
|
|
|
df[["juntes uprn", "junte found address", "junte found epc", "junte score"]] = (
|
|
df.progress_apply(extract_uprn, axis=1)
|
|
)
|
|
|
|
df.to_excel(f"{file_name}_outputs.xlsx", index=False)
|
|
|
|
# TODO: add lexiscore
|
|
# TODO: run it
|
|
# TODO: give it to danny
|