Skip to content

Commit

Permalink
Expand docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed Oct 25, 2023
1 parent 957a577 commit 947438a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
16 changes: 11 additions & 5 deletions audformat/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,21 @@ def concat(
a custom aggregation function can be provided
with ``aggregate_function``
that converts the overlapping values
into a single one.
into a single value.
Args:
objs: objects
overwrite: overwrite values where indices overlap
aggregate_function: function to be applied on all entries
that contain more then one data point per index.
The function gets a dataframe row as input,
and is expected to return a single value
aggregate_function: function to aggregate values
for all entries
that contain more than one value per index.
The function gets a dataframe row as input.
E.g. set to
:func:`numpy.mean`
to average the values
or to
``lambda row: tuple(row.to_list())``
to return all values as a tuple
Returns:
concatenated objects
Expand Down
8 changes: 8 additions & 0 deletions tests/test_utils_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,14 @@ def test_concat(objs, overwrite, expected):
np.mean,
pd.Series([1, 2], pd.Index(['a', 'b']), dtype='float'),
),
(
[
pd.Series([1, 2], pd.Index(['a', 'b']), dtype='float'),
pd.Series([1, 2], pd.Index(['a', 'b']), dtype='float'),
],
lambda x: tuple(x.to_list()),
pd.Series([(1, 1), (2, 2)], pd.Index(['a', 'b']), dtype='object'),
),
(
[
pd.Series([1, 2], pd.Index(['a', 'b']), dtype='float'),
Expand Down

0 comments on commit 947438a

Please sign in to comment.