From 62d5ca89e913a22e9451d552d04e5ea9c653bd42 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Tue, 17 Oct 2023 07:16:31 +0200 Subject: [PATCH] Fix accessing preequilibrationConditionId without checking for presence (#228) Fixes a bug in petab.visualize.data_overview.create_report which fails if there is no preequilibrationConditionId column in the measurements table. --- petab/visualize/data_overview.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/petab/visualize/data_overview.py b/petab/visualize/data_overview.py index 4878b312..c7d9fd41 100644 --- a/petab/visualize/data_overview.py +++ b/petab/visualize/data_overview.py @@ -61,13 +61,14 @@ def get_data_per_observable(measurement_df: pd.DataFrame) -> pd.DataFrame: """ my_measurements = measurement_df.copy() - my_measurements[PREEQUILIBRATION_CONDITION_ID] = my_measurements[ - PREEQUILIBRATION_CONDITION_ID - ].astype("object") index = [SIMULATION_CONDITION_ID] if PREEQUILIBRATION_CONDITION_ID in my_measurements: - my_measurements[PREEQUILIBRATION_CONDITION_ID].fillna("", inplace=True) + my_measurements[PREEQUILIBRATION_CONDITION_ID] = ( + my_measurements[PREEQUILIBRATION_CONDITION_ID] + .astype("object") + .fillna("", inplace=True) + ) index.append(PREEQUILIBRATION_CONDITION_ID) data_per_observable = pd.pivot_table(