added excluded uprns

This commit is contained in:
Khalim Conn-Kowlessar 2024-08-20 15:50:50 +01:00
parent 9436bfe7d6
commit 9938dea190
3 changed files with 19 additions and 4 deletions

View file

@ -60,6 +60,7 @@ class Ownership:
average_property_value: float,
portfolio_value: float,
excluded_owners: List[str] = None,
excluded_uprns: List[int] = None,
):
"""
@ -85,6 +86,7 @@ class Ownership:
self.land_registry_path = land_registry_path
self.excluded_owners = [] if excluded_owners is None else excluded_owners
self.excluded_uprns = [] if excluded_uprns is None else excluded_uprns
self.run_timestamp = str(datetime.now())
self.project_name = project_name
@ -204,6 +206,10 @@ class Ownership:
data.append(epc_data)
self.epc_data = pd.concat(data, ignore_index=True)
if self.excluded_uprns:
self.epc_data = self.epc_data[~self.epc_data["UPRN"].astype(float).isin(self.excluded_uprns)]
# We now store the data in s3
save_excel_to_s3(
df=self.epc_data,

View file

@ -1,5 +1,12 @@
# These are the registration numbers for companies we've heard a reponse from, and cannot sell
OWNERS_WHO_CANT_SELL = [
# Al Rayan
"4483430"
# Al Rayan - they're the senior lender, not able to sell
"4483430",
# Ultrabarn - they're unwilling to sell and will sort any retrofits themselves
"2794851"
]
EXCLUDED_UPRNS = [
# This property no longer exists
200003827624
]

View file

@ -1,8 +1,9 @@
import pandas as pd
from sqlalchemy.orm import sessionmaker
from backend.app.db.connection import db_engine
from backend.app.db.models.portfolio import Portfolio, PortfolioUsers
from etl.ownership.Ownership import Ownership
from etl.ownership.config import OWNERS_WHO_CANT_SELL as EXCLUDED_OWNERS
from etl.ownership.config import OWNERS_WHO_CANT_SELL as EXCLUDED_OWNERS, EXCLUDED_UPRNS
from utils.s3 import save_csv_to_s3
# Set up the project configuration
@ -122,7 +123,8 @@ def app():
bucket=DATA_BUCKET,
average_property_value=PROPERTY_VALUE_ESTIMATE,
portfolio_value=PORTFOLIO_VALUE,
excluded_owners=EXCLUDED_OWNERS
excluded_owners=EXCLUDED_OWNERS,
excluded_uprns=EXCLUDED_UPRNS
)
ownership_instance.pipeline(column_filters=epc_column_filters)