Calling .isel()
on a timezone-aware dimension/index causes it to lose timezone information
#9307
Open
5 tasks done
Labels
What happened?
With a Dataset/DataArray containing a time dimension whose index uses the
datetime64[ns, utc]
(timezone-aware) dtype, if one calls.isel()
to slice say the first element in this dimension, the time coordinate in the resulting Dataset/DataArray will have reverted todatetime64[ns]
(i.e. timezone-naive).What did you expect to happen?
Resulting Dataset/DataArray should retain the timezone-awareness on the coordinate of the sliced time dimension/index and still use
datetime64[ns, utc]
dtypeMinimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
Tested with version
2024.3.0
and also2024.7.0
.Similar to #6416
Environment
INSTALLED VERSIONS
commit: None
python: 3.11.0 (main, Mar 1 2023, 18:26:19) [GCC 11.2.0]
python-bits: 64
OS: Linux
OS-release: 5.15.0-1064-azure
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: C.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: None
libnetcdf: None
xarray: 2024.7.0
pandas: 2.2.2
numpy: 2.0.1
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: 69.5.1
pip: 24.0
conda: None
pytest: None
mypy: None
IPython: 8.26.0
sphinx: None
The text was updated successfully, but these errors were encountered: