testing_examples = [ { "epc": { 'lmk-key': '948324269042014090409224502942098', 'address1': '15, Ringwood Crescent', 'address2': None, 'address3': None, 'postcode': 'TS19 9DN', 'building-reference-number': 1016769078, 'current-energy-rating': 'C', 'potential-energy-rating': 'B', 'current-energy-efficiency': 79, 'potential-energy-efficiency': 85, 'property-type': 'House', 'built-form': 'Semi-Detached', 'inspection-date': '2014-08-21', 'local-authority': 'E06000004', 'constituency': 'E14000970', 'county': None, 'lodgement-date': '2014-09-04', 'transaction-type': 'none of the above', 'environment-impact-current': 77, 'environment-impact-potential': 85, 'energy-consumption-current': 152, 'energy-consumption-potential': 103.0, 'co2-emissions-current': 2.2, 'co2-emiss-curr-per-floor-area': 30, 'co2-emissions-potential': 1.5, 'lighting-cost-current': 61.0, 'lighting-cost-potential': 47.0, 'heating-cost-current': 625.0, 'heating-cost-potential': 522.0, 'hot-water-cost-current': 100.0, 'hot-water-cost-potential': 71.0, 'total-floor-area': 74.0, 'energy-tariff': 'Single', 'mains-gas-flag': 'Y', 'floor-level': 'NODATA!', 'flat-top-storey': None, 'flat-storey-count': None, 'main-heating-controls': 2106.0, 'multi-glaze-proportion': 100.0, 'glazed-type': 'double glazing installed before 2002', 'glazed-area': 'Normal', 'extension-count': 0.0, 'number-habitable-rooms': 3.0, 'number-heated-rooms': 3.0, 'low-energy-lighting': 70.0, 'number-open-fireplaces': 0.0, 'hotwater-description': 'From main system', 'hot-water-energy-eff': 'Good', 'hot-water-env-eff': 'Good', 'floor-description': 'Solid, no insulation (assumed)', 'floor-energy-eff': None, 'floor-env-eff': None, 'windows-description': 'Fully double glazed', 'windows-energy-eff': 'Average', 'windows-env-eff': 'Average', 'walls-description': 'Cavity wall, filled cavity', 'walls-energy-eff': 'Good', 'walls-env-eff': 'Good', 'secondheat-description': 'Room heaters, mains gas', 'sheating-energy-eff': None, 'sheating-env-eff': None, 'roof-description': 'Pitched, 50 mm loft insulation', 'roof-energy-eff': 'Poor', 'roof-env-eff': 'Poor', 'mainheat-description': 'Boiler and radiators, mains gas', 'mainheat-energy-eff': 'Good', 'mainheat-env-eff': 'Good', 'mainheatcont-description': 'Programmer, room thermostat and TRVs', 'mainheatc-energy-eff': 'Good', 'mainheatc-env-eff': 'Good', 'lighting-description': 'Low energy lighting in 70% of fixed outlets', 'lighting-energy-eff': 'Very Good', 'lighting-env-eff': 'Very Good', 'main-fuel': 'mains gas (not community)', 'wind-turbine-count': 0.0, 'heat-loss-corridor': 'NO DATA!', 'unheated-corridor-length': None, 'floor-height': 2.5, 'photo-supply': 50.0, 'solar-water-heating-flag': None, 'mechanical-ventilation': 'natural', 'address': '15, Ringwood Crescent', 'local-authority-label': 'Stockton-on-Tees', 'constituency-label': 'Stockton North', 'posttown': 'STOCKTON-ON-TEES', 'construction-age-band': 'England and Wales: 1950-1966', 'lodgement-datetime': '2014-09-04 09:22:45', 'tenure': 'owner-occupied', 'fixed-lighting-outlets-count': 10.0, 'low-energy-fixed-light-count': 7.0, 'uprn': 100110195416.0, 'uprn-source': 'Address Matched' }, "heating_recommendation_descriptions": [ "Install an air source heat pump, and upgrade heating controls to Smart Thermostats, room sensors and " "smart radiator valves (time & temperature zone control). The cost includes the £7500 boiler upgrade " "scheme grant", ], "heating_controls_recommendation_descriptions": [ "Upgrade heating controls to Smart Thermostats, room sensors and smart radiator valves (time & " "temperature zone control)" ], "notes": "This property has a boiler, radiators & mains gas with good efficiency so the only recommendation" "we expect here is for an air source heat pump. The heating controls are a programmer, room thermostat" "and TRVs and so we should expect a TTZC recommendation" }, { "epc": { 'lmk-key': '153995620832008100717310934068296', 'address1': 'Apartment 13 The Quays', 'address2': 'Burscough', 'address3': None, 'postcode': 'L40 5TW', 'building-reference-number': 2604281568, 'current-energy-rating': 'C', 'potential-energy-rating': 'B', 'current-energy-efficiency': 69, 'potential-energy-efficiency': 84, 'property-type': 'Flat', 'built-form': 'Detached', 'inspection-date': '2008-10-06', 'local-authority': 'E07000127', 'constituency': 'E14001033', 'county': 'Lancashire', 'lodgement-date': '2008-10-07', 'transaction-type': 'marketed sale', 'environment-impact-current': 78, 'environment-impact-potential': 78, 'energy-consumption-current': 195, 'energy-consumption-potential': 192.0, 'co2-emissions-current': 1.7, 'co2-emiss-curr-per-floor-area': 29, 'co2-emissions-potential': 1.7, 'lighting-cost-current': 35, 'lighting-cost-potential': 38, 'heating-cost-current': 108, 'heating-cost-potential': 89, 'hot-water-cost-current': 256, 'hot-water-cost-potential': 104, 'total-floor-area': 57.2, 'energy-tariff': 'Single', 'mains-gas-flag': 'N', 'floor-level': '1st', 'flat-top-storey': 'Y', 'flat-storey-count': 2.0, 'main-heating-controls': 2603.0, 'multi-glaze-proportion': 100.0, 'glazed-type': 'double glazing installed during or after 2002', 'glazed-area': 'Normal', 'extension-count': 0.0, 'number-habitable-rooms': 3.0, 'number-heated-rooms': 3.0, 'low-energy-lighting': 77.0, 'number-open-fireplaces': 0.0, 'hotwater-description': 'Electric immersion, standard tariff', 'hot-water-energy-eff': 'Very Poor', 'hot-water-env-eff': 'Poor', 'floor-description': '(other premises below)', 'floor-energy-eff': None, 'floor-env-eff': None, 'windows-description': 'Fully double glazed', 'windows-energy-eff': 'Good', 'windows-env-eff': 'Good', 'walls-description': 'Cavity wall, as built, insulated (assumed)', 'walls-energy-eff': 'Good', 'walls-env-eff': 'Good', 'secondheat-description': 'Portable electric heaters', 'sheating-energy-eff': None, 'sheating-env-eff': None, 'roof-description': '(another dwelling above)', 'roof-energy-eff': None, 'roof-env-eff': None, 'mainheat-description': 'Room heaters, electric', 'mainheat-energy-eff': 'Very Poor', 'mainheat-env-eff': 'Poor', 'mainheatcont-description': 'Programmer and appliance thermostats', 'mainheatc-energy-eff': 'Good', 'mainheatc-env-eff': 'Good', 'lighting-description': 'Low energy lighting in 77% of fixed outlets', 'lighting-energy-eff': 'Very Good', 'lighting-env-eff': 'Very Good', 'main-fuel': 'electricity - this is for backwards compatibility only and should not be used', 'wind-turbine-count': 0.0, 'heat-loss-corridor': 'heated corridor', 'unheated-corridor-length': None, 'floor-height': 2.3, 'photo-supply': 0.0, 'solar-water-heating-flag': 'N', 'mechanical-ventilation': 'natural', 'address': 'Apartment 13 The Quays, Burscough', 'local-authority-label': 'West Lancashire', 'constituency-label': 'West Lancashire', 'posttown': 'ORMSKIRK', 'construction-age-band': 'England and Wales: 2003-2006', 'lodgement-datetime': '2008-10-07 17:31:09', 'tenure': 'owner-occupied', 'fixed-lighting-outlets-count': None, 'low-energy-fixed-light-count': None, 'uprn': 10012342725.0, 'uprn-source': 'Address Matched', 'used': None }, "heating_recommendation_descriptions": [ "Install high heat retention electric storage heaters and upgrade heating controls to High Heat Retention " "Storage Heater Controls" ], "heating_controls_recommendation_descriptions": [], "notes": "This property has electric room heaters and is off gas so a boiler recommendation is not appropriate." "We would expect a high heat retention storage recommendation. The property is a flat and therefore" "we don't expect an air source heat pump recommendation. We also wouldn't expect a specific heating" "control recommendation here" }, { 'lmk-key': '751851300152012022010205497220090', 'address1': '21, Fullers Close', 'address2': 'Kelvedon', 'address3': None, 'postcode': 'CO5 9JX', 'building-reference-number': 8075968, 'current-energy-rating': 'D', 'potential-energy-rating': 'D', 'current-energy-efficiency': 55, 'potential-energy-efficiency': 56, 'property-type_x': 'Bungalow', 'built-form_x': 'Detached', 'inspection-date': '2012-02-20', 'local-authority': 'E07000067', 'constituency': 'E14001045', 'county': 'Essex', 'lodgement-date': '2012-02-20', 'transaction-type': 'non marketed sale', 'environment-impact-current': 39, 'environment-impact-potential': 39, 'energy-consumption-current': 475, 'energy-consumption-potential': 472.0, 'co2-emissions-current': 5.4, 'co2-emiss-curr-per-floor-area': 84, 'co2-emissions-potential': 5.4, 'lighting-cost-current': 53.0, 'lighting-cost-potential': 40.0, 'heating-cost-current': 674.0, 'heating-cost-potential': 678.0, 'hot-water-cost-current': 110.0, 'hot-water-cost-potential': 110.0, 'total-floor-area': 64.45, 'energy-tariff': 'dual', 'mains-gas-flag': 'N', 'floor-level': 'NODATA!', 'flat-top-storey': None, 'flat-storey-count': None, 'main-heating-controls': '2402', 'multi-glaze-proportion': 100.0, 'glazed-type': 'double glazing installed before 2002', 'glazed-area': 'Normal', 'extension-count': 0.0, 'number-habitable-rooms': 3.0, 'number-heated-rooms': 3.0, 'low-energy-lighting': 67.0, 'number-open-fireplaces': 0.0, 'hotwater-description': 'Electric immersion, off-peak', 'hot-water-energy-eff': 'Average', 'hot-water-env-eff': 'Very Poor', 'floor-description': 'Suspended, no insulation (assumed)', 'floor-energy-eff': None, 'floor-env-eff': None, 'windows-description': 'Fully double glazed', 'windows-energy-eff': 'Average', 'windows-env-eff': 'Average', 'walls-description': 'Cavity wall, as built, insulated (assumed)', 'walls-energy-eff': 'Good', 'walls-env-eff': 'Good', 'secondheat-description': 'Room heaters, electric', 'sheating-energy-eff': None, 'sheating-env-eff': None, 'roof-description': 'Pitched, 300+ mm loft insulation', 'roof-energy-eff': 'Very Good', 'roof-env-eff': 'Very Good', 'mainheat-description': 'Electric storage heaters', 'mainheat-energy-eff': 'Poor', 'mainheat-env-eff': 'Very Poor', 'mainheatcont-description': 'Automatic charge control', 'mainheatc-energy-eff': 'Average', 'mainheatc-env-eff': 'Average', 'lighting-description': 'Low energy lighting in 67% of fixed outlets', 'lighting-energy-eff': 'Good', 'lighting-env-eff': 'Good', 'main-fuel': 'electricity (not community)', 'wind-turbine-count': 0.0, 'heat-loss-corridor': 'NO DATA!', 'unheated-corridor-length': None, 'floor-height': 2.38, 'photo-supply': 0.0, 'solar-water-heating-flag': None, 'mechanical-ventilation': 'natural', 'address': '21, Fullers Close, Kelvedon', 'local-authority-label': 'Braintree', 'constituency-label': 'Witham', 'posttown': 'COLCHESTER', 'construction-age-band': 'England and Wales: 1983-1990', 'lodgement-datetime': '2012-02-20 10:20:54', 'tenure': 'owner-occupied', 'fixed-lighting-outlets-count': 6.0, 'low-energy-fixed-light-count': 4.0, 'uprn': 100090311351.0, 'uprn-source': 'Address Matched', 'property-type_y': None, 'built-form_y': None, 'used': None } ] import random from pathlib import Path import inspect import pandas as pd # this can be used to get example data to build the test cases src_file_path = inspect.getfile(lambda: None) EPC_DIRECTORY = Path(src_file_path).parent / "local_data" / "all-domestic-certificates" epc_directories = [entry for entry in EPC_DIRECTORY.iterdir() if entry.is_dir()] directory = random.sample(epc_directories, 1)[0] data = pd.read_csv(directory / "certificates.csv", low_memory=False) # Rename the columns to the same format as the api returns data.columns = [c.replace("_", "-").lower() for c in data.columns] used_examples = pd.DataFrame( [ { "mainheat-description": x["epc"]["mainheat-description"], "mainheat-energy-eff": x["epc"]["mainheat-energy-eff"], "property-type": x["epc"]["property-type"], "built-form": x["epc"]["built-form"], "used": True } for x in testing_examples ] ) data = data.merge(used_examples, how="left", on=["mainheat-description", "mainheat-energy-eff"]) data = data[pd.isnull(data["used"])] eg = data.sample(1).to_dict("records")[0]