diff --git a/xarray/core/groupby.py b/xarray/core/groupby.py index fec8954c9e2..54499c16e90 100644 --- a/xarray/core/groupby.py +++ b/xarray/core/groupby.py @@ -579,7 +579,7 @@ def _maybe_unstack(self, obj): obj._indexes = filter_indexes_from_coords(obj._indexes, set(obj.coords)) return obj - def _flox_reduce(self, dim, **kwargs): + def _flox_reduce(self, dim, keep_attrs=None, **kwargs): """Adaptor function that translates our groupby API to that of flox.""" from flox.xarray import xarray_reduce @@ -587,6 +587,9 @@ def _flox_reduce(self, dim, **kwargs): obj = self._original_obj + if keep_attrs is None: + keep_attrs = _get_keep_attrs(default=False) + # preserve current strategy (approximately) for dask groupby. # We want to control the default anyway to prevent surprises # if flox decides to change its default @@ -664,6 +667,7 @@ def _flox_reduce(self, dim, **kwargs): dim=dim, expected_groups=expected_groups, isbin=isbin, + keep_attrs=keep_attrs, **kwargs, )