From adf62d56db6294b68c215a6e84d1a283413b9bc5 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Tue, 2 May 2023 12:39:51 -0400 Subject: [PATCH] fixed bug not printing results when building not processed --- results.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/results.py b/results.py index c00c167..bd4beb2 100644 --- a/results.py +++ b/results.py @@ -11,22 +11,30 @@ class Results: def print(self): print_results = None file = 'city name: ' + self._city.name + '\n' + array = [None] * 12 for building in self._city.buildings: if cte.MONTH in building.heating.keys(): heating_results = building.heating[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} heating Wh'}) + else: + heating_results = pd.DataFrame(array, columns=[f'{building.name} heating Wh']) + if cte.MONTH in building.cooling.keys(): cooling_results = building.cooling[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} cooling Wh'}) + else: + cooling_results = pd.DataFrame(array, columns=[f'{building.name} cooling Wh']) + if cte.MONTH in building.lighting_electrical_demand.keys(): lighting_results = building.lighting_electrical_demand[cte.MONTH]\ .rename(columns={cte.INSEL_MEB: f'{building.name} lighting electrical demand Wh'}) - appliances_results = building.appliances_electrical_demand[cte.MONTH]\ + else: + lighting_results = pd.DataFrame(array, columns=[f'{building.name} lighting electrical demand Wh']) + if cte.MONTH in building.appliances_electrical_demand.keys(): + appliances_results = building.appliances_electrical_demand[cte.MONTH]\ .rename(columns={cte.INSEL_MEB: f'{building.name} appliances electrical demand Wh'}) + else: + appliances_results = pd.DataFrame(array, columns=[f'{building.name} appliances electrical demand Wh']) + if cte.MONTH in building.domestic_hot_water_heat_demand.keys(): dhw_results = building.domestic_hot_water_heat_demand[cte.MONTH]\ .rename(columns={cte.INSEL_MEB: f'{building.name} domestic hot water demand Wh'}) else: - array = [None] * 12 - heating_results = pd.DataFrame(array, columns=[f'{building.name} heating Wh']) - cooling_results = pd.DataFrame(array, columns=[f'{building.name} cooling Wh']) - lighting_results = pd.DataFrame(array, columns=[f'{building.name} lighting electrical demand Wh']) - appliances_results = pd.DataFrame(array, columns=[f'{building.name} appliances electrical demand Wh']) dhw_results = pd.DataFrame(array, columns=[f'{building.name} domestic hot water demand Wh']) if print_results is None: print_results = heating_results