Skip to content

Commit deec828

Browse files
committed
Fix first, last
1 parent 6d8e822 commit deec828

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

xarray/core/groupby.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
safe_cast_to_index,
3434
)
3535
from xarray.core.options import _get_keep_attrs
36-
from xarray.core.pycompat import integer_types
3736
from xarray.core.types import Dims, QuantileMethods, T_DataArray, T_Xarray
3837
from xarray.core.utils import (
3938
either_dict_or_kwargs,
@@ -1296,7 +1295,11 @@ def where(self, cond, other=dtypes.NA) -> T_Xarray:
12961295
return ops.where_method(self, cond, other)
12971296

12981297
def _first_or_last(self, op, skipna, keep_attrs):
1299-
if isinstance(self._group_indices[0], integer_types):
1298+
if all(
1299+
isinstance(maybe_slice, slice)
1300+
and (maybe_slice.stop == maybe_slice.start + 1)
1301+
for maybe_slice in self._group_indices
1302+
):
13001303
# NB. this is currently only used for reductions along an existing
13011304
# dimension
13021305
return self._obj

0 commit comments

Comments
 (0)