From 79b4833fc66f4fb490a1291d392d5ef8bc2054e9 Mon Sep 17 00:00:00 2001 From: Maximilian Schmitt Date: Tue, 7 May 2024 18:06:28 +0200 Subject: [PATCH] fix if processing function returns empty table --- audinterface/core/segment.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/audinterface/core/segment.py b/audinterface/core/segment.py index b6c0385..0e3071c 100644 --- a/audinterface/core/segment.py +++ b/audinterface/core/segment.py @@ -582,18 +582,21 @@ def process_table( ends.extend(index.get_level_values("end") + start) labels.extend([[table.iloc[j].values] * len(index)]) labels = np.vstack(labels) + df_empty = False if labels.shape == (1, 0): labels = labels.squeeze() + df_empty = True index = audformat.segmented_index(files, starts, ends) if isinstance(table, pd.Series): table = pd.Series(labels, index, name=table.name, dtype=dtype) else: - labels = { - col: labels[:, icol].astype(dtypes[icol]) - for icol, col in enumerate(table.columns) - } + if not df_empty: + labels = { + col: labels[:, icol].astype(dtypes[icol]) + for icol, col in enumerate(table.columns) + } table = pd.DataFrame(labels, index) return table