Skip to content

Xarray resample().last() fails with Dask Cluster and flox for chunks containing only NaNs #458

@josephnowak

Description

@josephnowak

I'm getting the following error when I have flox installed and I try to run a resample with the last method:

TypeError: float() argument must be a string or a real number, not 'ReprObject'

You should be able to reproduce the error using this script:

import pandas as pd
import xarray as xr
import numpy as np

from dask.distributed import Client

client = Client()

arr = xr.DataArray(
    np.nan,
    coords={
        "date": pd.to_datetime(["2025-03-24", "2025-06-23"]),
    },
    dims=["date"]
).chunk(date=(1, 1))

arr.resample(date="QE").last().compute()

Xarray show_versions:

INSTALLED VERSIONS
------------------
commit: None
python: 3.11.13 (main, Jul 11 2025, 22:36:59) [MSC v.1944 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 165 Stepping 2, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: ('es_ES', 'cp1252')
libhdf5: None
libnetcdf: None

xarray: 2025.7.1
pandas: 2.3.1
numpy: 2.1.3
scipy: 1.15.3
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
zarr: 3.1.1
cftime: None
nc_time_axis: None
iris: None
bottleneck: 1.5.0
dask: 2025.7.0
distributed: 2025.7.0
matplotlib: None
cartopy: None
seaborn: None
numbagg: 0.9.0
fsspec: 2025.7.0
cupy: None
pint: None
sparse: 0.17.0
flox: 0.10.4
numpy_groupies: 0.11.3
setuptools: 80.3.1
pip: 25.1.1
conda: None
pytest: 8.4.1
mypy: None
IPython: 9.4.0
sphinx: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions