What happened?
A RangeIndex built from datetime64 start/stop and a timedelta64 step works: labels are computed correctly, and isel and sel(method="nearest") keep the index lazy. But its repr formats start, stop and step with :.3g, which only real numbers accept, so printing the index, or any DataArray/Dataset which holds it, raises.
A lazy time axis is the main reason we want RangeIndex: a long, evenly sampled acquisition has 1e8+ time labels and a handful of channels, so the time coordinate is the one worth not materializing.
What did you expect to happen?
The repr to print, as it does for a float range, e.g.
Indexes:
time RangeIndex (start=2023-01-01T00:00:00.000000000, stop=2023-01-01T00:00:10.000000000, step=1 seconds)
Minimal Complete Verifiable Example
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "xarray[complete]@git+https://github.com/pydata/xarray.git@main",
# ]
# ///
#
# This script automatically imports the development branch of xarray to check for issues.
# Please delete this header if you have _not_ tested this script with `uv run`!
import xarray as xr
import numpy as np
from xarray.indexes import RangeIndex
xr.show_versions()
t0 = np.datetime64("2023-01-01", "ns")
step = np.timedelta64(1, "s")
index = RangeIndex.arange(t0, t0 + 10 * step, step, dim="time")
da = xr.DataArray(np.zeros(10), dims="time", coords=xr.Coordinates.from_xindex(index))
print(da.time.values[:2]) # ['2023-01-01T00:00:00.000000000' '2023-01-01T00:00:01.000000000']
print(da)
Steps to reproduce
Just run it
MVCE confirmation
Relevant log output
Anything else we need to know?
No response
Environment
Details
Reproduced on both, in clean uv environments:
xarray 2026.7.0 (latest release)
xarray 2026.7.1.dev56+g8de862c29 (main at commit 8de862c, 2026-09-21)
INSTALLED VERSIONS
commit: None
python: 3.13.1 (main, Dec 6 2024, 18:40:43) [Clang 18.1.8 ]
python-bits: 64
OS: Linux
OS-release: 7.0.0-31-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: None
libnetcdf: None
xarray: 2026.7.0
pandas: 3.0.6
numpy: 2.5.3
scipy: None
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
zarr: None
cftime: None
nc_time_axis: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
fsspec: None
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: None
pip: 24.3.1
conda: None
pytest: None
mypy: None
IPython: None
sphinx: None
What happened?
A
RangeIndexbuilt fromdatetime64start/stop and atimedelta64step works: labels are computed correctly, andiselandsel(method="nearest")keep the index lazy. But its repr formatsstart,stopandstepwith:.3g, which only real numbers accept, so printing the index, or anyDataArray/Datasetwhich holds it, raises.A lazy time axis is the main reason we want
RangeIndex: a long, evenly sampled acquisition has 1e8+ time labels and a handful of channels, so the time coordinate is the one worth not materializing.What did you expect to happen?
The repr to print, as it does for a float range, e.g.
Minimal Complete Verifiable Example
Steps to reproduce
Just run it
MVCE confirmation
Relevant log output
Anything else we need to know?
No response
Environment
Details
Reproduced on both, in clean uv environments:
xarray 2026.7.0 (latest release)
xarray 2026.7.1.dev56+g8de862c29 (main at commit 8de862c, 2026-09-21)
INSTALLED VERSIONS
commit: None
python: 3.13.1 (main, Dec 6 2024, 18:40:43) [Clang 18.1.8 ]
python-bits: 64
OS: Linux
OS-release: 7.0.0-31-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: None
libnetcdf: None
xarray: 2026.7.0
pandas: 3.0.6
numpy: 2.5.3
scipy: None
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
zarr: None
cftime: None
nc_time_axis: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
fsspec: None
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: None
pip: 24.3.1
conda: None
pytest: None
mypy: None
IPython: None
sphinx: None