Skip to content

Commit

Permalink
moving dtypes and adding description
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilian Schmitt committed May 15, 2024
1 parent 5a8d9e8 commit 0d47e90
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions audinterface/core/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -570,15 +573,13 @@ 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)
ends.extend(index.get_level_values("end") + start)
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)
Expand All @@ -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]
Expand Down

0 comments on commit 0d47e90

Please sign in to comment.