Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Mar 30, 2023
1 parent a2290aa commit e863045
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion xarray/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,14 @@ def factorize(self, squeeze: bool) -> None:

def _validate_group(obj, group):
from xarray.core.dataarray import DataArray
from xarray.core.dataset import Dataset

if isinstance(group, (DataArray, IndexVariable)):
name = group.name or "group"
newobj = obj.copy()
if group.name in newobj:
if group.name in newobj.coords or (
isinstance(newobj, Dataset) and group.name in newobj.data_vars
):
newobj[group.name] = group
else:
try:
Expand Down

0 comments on commit e863045

Please sign in to comment.