Skip to content
forked from pydata/xarray

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Nov 2, 2022
1 parent ab4ad06 commit c9e2a62
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions xarray/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,19 @@ def __repr__(self) -> str:

def _iter_grouped(self) -> Iterator[T_Xarray]:
"""Iterate over each element in this group"""
for indices in self._group_indices:
yield self._obj.isel({self._group_dim: indices})
print(self._group_indices)
if isinstance(self._group_indices[0], slice):
for indices in self._group_indices:
yield self._obj.isel({self._group_dim: indices})
else:
for code in np.sort(pd.unique(self._codes.data.reshape(-1))):
if code == -1:
continue
subset = self._original_obj.where(self._codes == code, drop=True)
if self._squeeze:
squeeze_dims = tuple(dim for dim in self._codes.dims if subset.sizes[dim] == 1)
subset = subset.squeeze(squeeze_dims)
yield subset

def _infer_concat_args(self, applied_example):
if self._group_dim in applied_example.dims:
Expand Down

0 comments on commit c9e2a62

Please sign in to comment.