xarray.core.groupby.DataArrayGroupBy#

class xarray.core.groupby.DataArrayGroupBy(obj, group, squeeze=False, grouper=None, bins=None, restore_coord_dims=True, cut_kwargs=None)[source]#
__init__(obj, group, squeeze=False, grouper=None, bins=None, restore_coord_dims=True, cut_kwargs=None)[source]#

Create a GroupBy object

Parameters
  • obj (Dataset or DataArray) – Object to group.

  • group (Hashable, DataArray or Index) – Array with the group values or name of the variable.

  • squeeze (bool, default: False) – If “group” is a coordinate of object, squeeze controls whether the subarrays have a dimension of length 1 along that coordinate or if the dimension is squeezed out.

  • grouper (pandas.Grouper, optional) – Used for grouping values along the group array.

  • bins (array-like, optional) – If bins is specified, the groups will be discretized into the specified bins by pandas.cut.

  • restore_coord_dims (bool, default: True) – If True, also restore the dimension order of multi-dimensional coordinates.

  • cut_kwargs (dict-like, optional) – Extra keyword arguments to pass to pandas.cut

Methods

__init__(obj, group[, squeeze, grouper, ...])

Create a GroupBy object

all([dim, keep_attrs])

Reduce this DataArray's data by applying all along some dimension(s).

any([dim, keep_attrs])

Reduce this DataArray's data by applying any along some dimension(s).

apply(func[, shortcut, args])

Backward compatible implementation of map

assign_coords([coords])

Assign coordinates by group.

count([dim, keep_attrs])

Reduce this DataArray's data by applying count along some dimension(s).

cumprod([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying cumprod along some dimension(s).

cumsum([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying cumsum along some dimension(s).

fillna(value)

Fill missing values in this object by group.

first([skipna, keep_attrs])

Return the first element of each group along the group dimension

last([skipna, keep_attrs])

Return the last element of each group along the group dimension

map(func[, args, shortcut])

Apply a function to each array in the group and concatenate them together into a new array.

max([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying max along some dimension(s).

mean([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying mean along some dimension(s).

median([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying median along some dimension(s).

min([dim, skipna, keep_attrs])

Reduce this DataArray's data by applying min along some dimension(s).

prod([dim, skipna, min_count, keep_attrs])

Reduce this DataArray's data by applying prod along some dimension(s).

quantile(q[, dim, method, keep_attrs, ...])

Compute the qth quantile over each array in the groups and concatenate them together into a new array.

reduce(func[, dim, axis, keep_attrs, ...])

Reduce the items in this group by applying func along some dimension(s).

std([dim, skipna, ddof, keep_attrs])

Reduce this DataArray's data by applying std along some dimension(s).

sum([dim, skipna, min_count, keep_attrs])

Reduce this DataArray's data by applying sum along some dimension(s).

var([dim, skipna, ddof, keep_attrs])

Reduce this DataArray's data by applying var along some dimension(s).

where(cond[, other])

Return elements from self or other depending on cond.

Attributes

dims

groups

Mapping from group labels to indices.

sizes

Ordered mapping from dimension names to lengths.