diff --git a/flox/xarray.py b/flox/xarray.py index acd3f2d6c..487850ca0 100644 --- a/flox/xarray.py +++ b/flox/xarray.py @@ -374,8 +374,8 @@ def wrapper(array, *by, func, skipna, core_dims, **kwargs): # xarray always uses np.datetime64[ns] for np.datetime64 data dtype = "timedelta64[ns]" array = datetime_to_numeric(array, offset) - elif _contains_cftime_datetimes(array): - offset = min(array) + elif is_cftime: + offset = array.min() array = datetime_to_numeric(array, offset, datetime_unit="us") result, *groups = groupby_reduce(array, *by, func=func, **kwargs) diff --git a/flox/xrutils.py b/flox/xrutils.py index 45cf45eec..958bd3976 100644 --- a/flox/xrutils.py +++ b/flox/xrutils.py @@ -157,7 +157,7 @@ def datetime_to_numeric(array, offset=None, datetime_unit=None, dtype=float): if array.dtype.kind in "Mm": offset = _datetime_nanmin(array) else: - offset = min(array) + offset = array.min() # Compute timedelta object. # For np.datetime64, this can silently yield garbage due to overflow.