xarray.Dataset.groupby#
- Dataset.groupby(group, squeeze=True, restore_coord_dims=False)[source]#
Returns a DatasetGroupBy object for performing grouped operations.
- Parameters:
group (
Hashable
,DataArray
orIndexVariable
) – Array whose unique values should be used to group this array. If a string, must be the name of a variable contained in this dataset.squeeze (
bool
, default:True
) – If “group” is a dimension of any arrays in this dataset, squeeze controls whether the subarrays have a dimension of length 1 along that dimension or if the dimension is squeezed out.restore_coord_dims (
bool
, default:False
) – If True, also restore the dimension order of multi-dimensional coordinates.
- Returns:
grouped (
DatasetGroupBy
) – A DatasetGroupBy object patterned after pandas.GroupBy that can be iterated over in the form of (unique_value, grouped_array) pairs.
See also
- GroupBy: Group and Bin Data
Users guide explanation of how to group and bin data.
Dataset.groupby_bins
,DataArray.groupby
,core.groupby.DatasetGroupBy
,pandas.DataFrame.groupby
,Dataset.resample
,DataArray.resample