# xarray.core.groupby.DataArrayGroupBy.apply¶

DataArrayGroupBy.apply(func, shortcut=False, **kwargs)

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

func is called like func(ar, *args, **kwargs) for each array ar in this group.

Apply uses heuristics (like pandas.GroupBy.apply) to figure out how to stack together the array. The rule is: 1. If the dimension along which the group coordinate is defined is

still in the first grouped array after applying func, then stack over this dimension.
1. Otherwise, stack over the new dimension given by name of this grouping (the argument to the groupby function).
Parameters: func : function Callable to apply to each array. shortcut : bool, optional Whether or not to shortcut evaluation under the assumptions that: (1) The action of func does not depend on any of the array metadata (attributes or coordinates) but only on the data and dimensions. The action of func creates arrays with homogeneous metadata, that is, with the same dimensions and attributes. If these conditions are satisfied shortcut provides significant speedup. This should be the case for many common groupby operations (e.g., applying numpy ufuncs). **kwargs Used to call func(ar, **kwargs) for each array ar. applied : DataArray or DataArray The result of splitting, applying and combining this array.