From 9938dea1904e6cd14fc882d65ea5ca0ed1329967 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 20 Aug 2024 15:50:50 +0100 Subject: [PATCH] added excluded uprns --- etl/ownership/Ownership.py | 6 ++++++ etl/ownership/config.py | 11 +++++++++-- etl/ownership/projects/midlands_portfolio/app.py | 6 ++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/etl/ownership/Ownership.py b/etl/ownership/Ownership.py index 9e328452..a3aa9e15 100644 --- a/etl/ownership/Ownership.py +++ b/etl/ownership/Ownership.py @@ -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, diff --git a/etl/ownership/config.py b/etl/ownership/config.py index c737d532..1940e06d 100644 --- a/etl/ownership/config.py +++ b/etl/ownership/config.py @@ -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 ] diff --git a/etl/ownership/projects/midlands_portfolio/app.py b/etl/ownership/projects/midlands_portfolio/app.py index bf18d846..99b8fc48 100644 --- a/etl/ownership/projects/midlands_portfolio/app.py +++ b/etl/ownership/projects/midlands_portfolio/app.py @@ -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)