diff --git a/xarray/core/groupby.py b/xarray/core/groupby.py index 83fa8b5c138..3769bd081f1 100644 --- a/xarray/core/groupby.py +++ b/xarray/core/groupby.py @@ -101,6 +101,8 @@ def __init__(self, obj, group, squeeze=False, grouper=None): """ from .dataset import as_dataset + if getattr(group, 'name', None) is None: + raise ValueError('`group` must have a name') self._stacked_dim = None group_name = group.name if group.ndim != 1: @@ -119,8 +121,6 @@ def __init__(self, obj, group, squeeze=False, grouper=None): # we also need to rename the group name to avoid a conflict when # concatenating group_name += '_groups' - if getattr(group, 'name', None) is None: - raise ValueError('`group` must have a name') if not hasattr(group, 'dims'): raise ValueError("`group` must have a 'dims' attribute") group_dim, = group.dims @@ -412,7 +412,7 @@ def _concat(self, applied, shortcut=False): # peek at applied to determine which coordinate to stack over applied_example, applied = peek_at(applied) concat_dim, positions = self._infer_concat_args(applied_example) - + print('concat_dim and positions', concat_dim, positions) if shortcut: combined = self._concat_shortcut(applied, concat_dim, positions) else: