From 0d47e90d7f17a48983a4d2205badb50668b891ed Mon Sep 17 00:00:00 2001 From: Maximilian Schmitt Date: Wed, 15 May 2024 11:17:26 +0200 Subject: [PATCH] moving dtypes and adding description --- audinterface/core/segment.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/audinterface/core/segment.py b/audinterface/core/segment.py index 26bb0b0..a389dc2 100644 --- a/audinterface/core/segment.py +++ b/audinterface/core/segment.py @@ -515,6 +515,9 @@ def process_table( ) -> typing.Union[pd.Series, pd.DataFrame]: r"""Segment files or segments from a table. + The labels of the table + are reassigned to the new segments. + If ``cache_root`` is not ``None``, a hash value is created from the index using :func:`audformat.utils.hash` and @@ -570,7 +573,6 @@ def process_table( ends = [] labels = [] if isinstance(table, pd.Series): - dtype = table.dtype for j, ((file, start, _), index) in enumerate(y.items()): files.extend([file] * len(index)) starts.extend(index.get_level_values("start") + start) @@ -578,7 +580,6 @@ def process_table( labels.extend([[table.iloc[j]] * len(index)]) labels = np.hstack(labels) else: - dtypes = [table[col].dtype for col in table.columns] for j, ((file, start, _), index) in enumerate(y.items()): files.extend([file] * len(index)) starts.extend(index.get_level_values("start") + start) @@ -593,8 +594,10 @@ def process_table( index = audformat.segmented_index(files, starts, ends) if isinstance(table, pd.Series): + dtype = table.dtype table = pd.Series(labels, index, name=table.name, dtype=dtype) else: + dtypes = [table[col].dtype for col in table.columns] labels = { col: pd.Series( labels[:, icol], index=index, dtype=dtypes[icol]