From 8f6d25522a97094739bc8a7c84145a6a60791b45 Mon Sep 17 00:00:00 2001 From: John Vouvakis Manousakis Date: Tue, 9 Apr 2024 17:09:24 -0700 Subject: [PATCH] Fix demand cloning bug While demand cloning was happening for the `sample` attribute, the units were left unchanged, leading to missing values down the line. It only took two lines of code to fix this, using the existing reindexing operation followed by normalizing the index of `units`. --- pelicun/model/demand_model.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pelicun/model/demand_model.py b/pelicun/model/demand_model.py index 26f934d47..474124c25 100644 --- a/pelicun/model/demand_model.py +++ b/pelicun/model/demand_model.py @@ -859,6 +859,9 @@ def turn_to_tuples(demand_cloning): self.sample = self.sample.iloc[:, column_index] # update the column index self.sample.columns = pd.MultiIndex.from_tuples(column_values) + # update units + self.units = self.units.iloc[column_index] + self.units.index = self.sample.columns def generate_sample(self, config): """