@@ -1357,12 +1357,7 @@ def where(self, cond, other=dtypes.NA) -> T_Xarray:
1357
1357
"""
1358
1358
return ops .where_method (self , cond , other )
1359
1359
1360
- def _first_or_last (
1361
- self ,
1362
- op : Literal ["first" | "last" ],
1363
- skipna : bool | None ,
1364
- keep_attrs : bool | None ,
1365
- ):
1360
+ def _first_or_last (self , op , skipna , keep_attrs ):
1366
1361
if all (
1367
1362
isinstance (maybe_slice , slice )
1368
1363
and (maybe_slice .stop == maybe_slice .start + 1 )
@@ -1373,30 +1368,17 @@ def _first_or_last(
1373
1368
return self ._obj
1374
1369
if keep_attrs is None :
1375
1370
keep_attrs = _get_keep_attrs (default = True )
1376
- if (
1377
- module_available ("flox" , minversion = "0.9.16" )
1378
- and OPTIONS ["use_flox" ]
1379
- and contains_only_chunked_or_numpy (self ._obj )
1380
- ):
1381
- result , * _ = self ._flox_reduce (
1382
- dim = None , func = op , skipna = skipna , keep_attrs = keep_attrs
1383
- )
1384
- else :
1385
- result = self .reduce (
1386
- getattr (duck_array_ops , op ),
1387
- dim = [self ._group_dim ],
1388
- skipna = skipna ,
1389
- keep_attrs = keep_attrs ,
1390
- )
1391
- return result
1371
+ return self .reduce (
1372
+ op , dim = [self ._group_dim ], skipna = skipna , keep_attrs = keep_attrs
1373
+ )
1392
1374
1393
1375
def first (self , skipna : bool | None = None , keep_attrs : bool | None = None ):
1394
1376
"""Return the first element of each group along the group dimension"""
1395
- return self ._first_or_last (" first" , skipna , keep_attrs )
1377
+ return self ._first_or_last (duck_array_ops . first , skipna , keep_attrs )
1396
1378
1397
1379
def last (self , skipna : bool | None = None , keep_attrs : bool | None = None ):
1398
1380
"""Return the last element of each group along the group dimension"""
1399
- return self ._first_or_last (" last" , skipna , keep_attrs )
1381
+ return self ._first_or_last (duck_array_ops . last , skipna , keep_attrs )
1400
1382
1401
1383
def assign_coords (self , coords = None , ** coords_kwargs ):
1402
1384
"""Assign coordinates by group.
0 commit comments