Coverage for install/scipp/core/groupby.py: 40%
5 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-17 01:51 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-17 01:51 +0000
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
3# @author Matthew Andrew
6from .._scipp import core as _cpp
9def groupby(
10 data: _cpp.DataArray | _cpp.Dataset,
11 /,
12 group: _cpp.Variable | str,
13 *,
14 bins: _cpp.Variable | None = None,
15) -> _cpp.GroupByDataArray | _cpp.GroupByDataset:
16 """Group dataset or data array based on values of specified labels.
18 Parameters
19 ----------
20 data:
21 Input data to reduce.
22 group:
23 Name of labels to use for grouping or Variable to use for grouping
24 bins:
25 Optional bins for grouping label values.
27 Returns
28 -------
29 :
30 GroupBy helper object.
31 """
32 if bins is None:
33 return _cpp.groupby(data, group)
34 else:
35 return _cpp.groupby(data, group, bins)