diff --git a/asset_list/AssetList.py b/asset_list/AssetList.py index f63c53b8..302b2f2f 100644 --- a/asset_list/AssetList.py +++ b/asset_list/AssetList.py @@ -1996,24 +1996,6 @@ class AssetList: self.standardised_asset_list[col] ) - blocks_of_flats = self.standardised_asset_list[ - self.standardised_asset_list[self.STANDARD_PROPERTY_TYPE] == "block of flats" - ] - - non_blocks_of_flats = self.standardised_asset_list[ - self.standardised_asset_list[self.STANDARD_PROPERTY_TYPE] != "block of flats" - ] - - # Produce some aggregate figures - self.work_type_figures = { - **non_blocks_of_flats["cavity_reason"].value_counts().to_dict(), - **{ - k + " (Block of flats)": v for k, v in - blocks_of_flats["solar_reason"].value_counts().to_dict().items() - }, - **self.standardised_asset_list["solar_reason"].value_counts().to_dict() - } - # We prepare outcomes for output if self.outcomes is not None: logger.info("Preparing outcomes for output") @@ -2044,6 +2026,26 @@ class AssetList: ) ) + def get_work_figures(self): + blocks_of_flats = self.standardised_asset_list[ + self.standardised_asset_list[self.STANDARD_PROPERTY_TYPE] == "block of flats" + ] + + non_blocks_of_flats = self.standardised_asset_list[ + self.standardised_asset_list[self.STANDARD_PROPERTY_TYPE] != "block of flats" + ] + + # Produce some aggregate figures + self.work_type_figures = { + **non_blocks_of_flats["cavity_reason"].value_counts().to_dict(), + **{ + k + " (Block of flats)": v for k, v in + blocks_of_flats["solar_reason"].value_counts().to_dict().items() + }, + **self.standardised_asset_list["solar_reason"].value_counts().to_dict() + } + pprint(self.work_type_figures) + def fill_landlord_block_reference(self, has_blocks_of_flats): if not has_blocks_of_flats: return @@ -3245,6 +3247,8 @@ class AssetList: scheme_col = "AFFORDABLE WARMTH" elif "Scheme" in master_data.columns: scheme_col = "Scheme" + elif "Affordable Warmth" in master_data.columns: + scheme_col = "Affordable Warmth" else: scheme_col = "OFFICE USE ONLY" diff --git a/asset_list/app.py b/asset_list/app.py index 9d3c39f7..63ccf9cf 100644 --- a/asset_list/app.py +++ b/asset_list/app.py @@ -59,26 +59,26 @@ def app(): Property UPRN """ - # Southern - Optivo list - data_folder = "/Users/khalimconn-kowlessar/Documents/hestia/Customers/Southern/New Programme" - data_filename = "OPTIVO List for Warmfront.xlsx" - sheet_name = "AddressProfilingResults" - postcode_column = 'PostCode' - fulladdress_column = "Address" - address1_column = None - address1_method = "house_number_extraction" - address_cols_to_concat = [] + # Southern - Jan list + data_folder = "/Users/khalimconn-kowlessar/Documents/hestia/Customers/Southern/New Programme/Jan 2025 List" + data_filename = "SOUTHERN ASSETS January 2025 Additions Query 21.03.2025.xlsx" + sheet_name = "Jan 2025 additions" + postcode_column = 'Post Code' + fulladdress_column = None + address1_column = "NO." + address1_method = None + address_cols_to_concat = ["NO.", "Street / Block Name", "Town/Area"] missing_postcodes_method = None - landlord_year_built = "Age" + landlord_year_built = None landlord_os_uprn = None - landlord_property_type = None - landlord_built_form = None - landlord_wall_construction = "Walls" - landlord_roof_construction = "Roofs" - landlord_heating_system = "Heating" + landlord_property_type = "Archetype" # Using the inspections property type + landlord_built_form = "Archetype" + landlord_wall_construction = None + landlord_roof_construction = None + landlord_heating_system = None landlord_existing_pv = None - landlord_property_id = "OrganisationReference" - landlord_sap = "SAP (9.92)" + landlord_property_id = "SH Property Reference" + landlord_sap = None outcomes_filename = [ os.path.join(data_folder, "RT - Southern Housing Group - JJC.xlsx"), os.path.join(data_folder, "RT - SOUTHERN OUTCOMES - SCIS Merged.xlsx"), @@ -634,6 +634,7 @@ def app(): # We now flag the status of the property asset_list.label_property_status() asset_list.analyse_geographies() + asset_list.get_work_figures() # Store as an excel filename = os.path.join(data_folder, ".".join(data_filename.split(".")[:-1])) + " - Standardised.xlsx" diff --git a/asset_list/mappings/heating_systems.py b/asset_list/mappings/heating_systems.py index 22896165..dced36a7 100644 --- a/asset_list/mappings/heating_systems.py +++ b/asset_list/mappings/heating_systems.py @@ -340,4 +340,6 @@ HEATING_MAPPINGS = { 'Electric Storage Systems: Integrated storage+direct-acting heater': 'electric storage heaters', 'Boiler: D rated Combi': 'gas condensing combi', 'Heat Pump: (from database)': 'air source heat pump', + 'Community Heating Systems: Community CHP and boilers (RdSAP)': 'communal heating', + '': 'unknown' } diff --git a/asset_list/mappings/roof.py b/asset_list/mappings/roof.py index 3221d71b..66860bec 100644 --- a/asset_list/mappings/roof.py +++ b/asset_list/mappings/roof.py @@ -171,4 +171,8 @@ ROOF_CONSTRUCTION_MAPPINGS = { 'PitchedNormalLoftAccess: 250mm, PitchedNormalLoftAccess: 50mm': 'pitched insulated', 'AnotherDwellingAbove: Unknown, PitchedNormalLoftAccess: 200mm': 'another dwelling above', + 'PitchedNormalNoLoftAccess: Unknown': 'pitched no access to loft', + 'PitchedNormalLoftAccess: Unknown': 'pitched unknown insulation', + 'AnotherDwellingAbove: Unknown': 'another dwelling above' + } diff --git a/asset_list/utils.py b/asset_list/utils.py index 1678b8e9..9affc326 100644 --- a/asset_list/utils.py +++ b/asset_list/utils.py @@ -1,5 +1,5 @@ import time -import numpy as np +import random import pandas as pd from backend.SearchEpc import SearchEpc from etl.find_my_epc.RetrieveFindMyEpc import RetrieveFindMyEpc @@ -172,7 +172,7 @@ def get_data( find_epc_data = {} except Exception as e: raise Exception(f"Error retrieving FindMyEPC data: {e}") - time.sleep(np.random.uniform(0.1, 1)) + time.sleep(random.sample(range(50, 100), 1)[0] / 100) epc = { row_id_name: home[row_id_name], @@ -182,6 +182,11 @@ def get_data( } epc_data.append(epc) + + if len(epc_data) % 50 == 0 and len(epc_data) > 0: + logger.info("Sleeping for 10 seconds to avoid hitting API rate limit") + time.sleep(10) + except Exception as e: errors.append(home[row_id_name]) time.sleep(5)