From 36b18876d66687997e17040ec10b7feb64414a64 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 19 Aug 2024 13:30:32 +0100 Subject: [PATCH] Added excluded owners --- etl/ownership/Ownership.py | 11 ++++++++++- etl/ownership/config.py | 5 +++++ etl/ownership/projects/midlands_portfolio/app.py | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 etl/ownership/config.py diff --git a/etl/ownership/Ownership.py b/etl/ownership/Ownership.py index cfa3e3b3..25ba7cea 100644 --- a/etl/ownership/Ownership.py +++ b/etl/ownership/Ownership.py @@ -58,7 +58,8 @@ class Ownership: project_name: str, bucket: str, average_property_value: float, - portfolio_value: float + portfolio_value: float, + excluded_owners: List[str] = None, ): """ @@ -83,6 +84,8 @@ class Ownership: self.overseas_ownership_path = overseas_ownership_path self.land_registry_path = land_registry_path + self.excluded_owners = [] if excluded_owners is None else excluded_owners + self.run_timestamp = str(datetime.now()) self.project_name = project_name self.bucket = bucket @@ -221,6 +224,12 @@ class Ownership: self.ownership_data["Postcode"].str.lower().isin(self.epc_data["POSTCODE"].str.lower().unique()) ] + logger.info("Removing excluded owners") + # Use the company registration number to filter out excluded owners + self.ownership_data = self.ownership_data[ + ~self.ownership_data["Company Registration No. (1)"].astype(str).isin(self.excluded_owners) + ] + def prepare_for_matching(self): """ Given the epc properties and the ownership data, this function performs a number of operations on both datasets diff --git a/etl/ownership/config.py b/etl/ownership/config.py new file mode 100644 index 00000000..c737d532 --- /dev/null +++ b/etl/ownership/config.py @@ -0,0 +1,5 @@ +# These are the registration numbers for companies we've heard a reponse from, and cannot sell +OWNERS_WHO_CANT_SELL = [ + # Al Rayan + "4483430" +] diff --git a/etl/ownership/projects/midlands_portfolio/app.py b/etl/ownership/projects/midlands_portfolio/app.py index 17baed07..5a4cf3f3 100644 --- a/etl/ownership/projects/midlands_portfolio/app.py +++ b/etl/ownership/projects/midlands_portfolio/app.py @@ -1,4 +1,5 @@ from etl.ownership.Ownership import Ownership +from etl.ownership.config import OWNERS_WHO_CANT_SELL as EXCLUDED_OWNERS # Set up the project configuration USER_IDS = [ @@ -70,7 +71,8 @@ def app(): project_name=PROJECT_NAME, bucket=DATA_BUCKET, average_property_value=PROPERTY_VALUE_ESTIMATE, - portfolio_value=PORTFOLIO_VALUE + portfolio_value=PORTFOLIO_VALUE, + EXCLUDED_OWNERS=EXCLUDED_OWNERS ) ownership_instance.pipeline(column_filters=epc_column_filters)