-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Code Sample, a copy-pastable example if possible
import datetime as dt
import xarray as xr
df = xr.Dataset({'day': [1,2],
'date':('day',[dt.datetime(2018,1,2),dt.datetime(2018,1,3)]),
"var": ('day', [ 5,6])})
print(df.indexes)
df_d=df.swap_dims({"day":"date"}).swap_dims({"date":"day"})
print(df_d.indexes)Problem description
When changing coordinate from integer to datetime to integer the indexes are still datetime object with version 0.12.0 while I expect Integer (as in version 0.11.3).
Indeed I get the following results :
day: Int64Index([1, 2], dtype='int64', name='day')
day: DatetimeIndex(['2018-01-02', '2018-01-03'], dtype='datetime64[ns]', name='day', freq=None)
Expected Output
With previous version of xarray I get the expected output.
day: Int64Index([1, 2], dtype='int64', name='day')
day: Int64Index([1, 2], dtype='int64', name='day')
Output of xr.show_versions()
Details
INSTALLED VERSIONS ------------------commit: None
python: 3.6.7 | packaged by conda-forge | (default, Feb 20 2019, 02:51:38)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.9.0-8-amd64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.4
libnetcdf: 4.6.2
xarray: 0.12.0
pandas: 0.24.2
numpy: 1.15.4
scipy: 1.2.1
netCDF4: 1.4.3.2
pydap: None
h5netcdf: None
h5py: 2.9.0
Nio: 1.5.5
zarr: None
cftime: 1.0.3.4
nc_time_axis: None
PseudonetCDF: None
rasterio: 1.0.22
cfgrib: None
iris: 2.2.0
bottleneck: None
dask: 1.1.4
distributed: 1.26.0
matplotlib: 3.0.3
cartopy: 0.17.0
seaborn: 0.9.0
setuptools: 40.8.0
pip: 19.0.3
conda: 4.6.8
pytest: 4.3.1
IPython: 7.3.0
sphinx: None
Output of previous xr.show_versions()
Details
INSTALLED VERSIONS ------------------commit: None
python: 3.6.7 | packaged by conda-forge | (default, Feb 20 2019, 02:51:38)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.9.0-8-amd64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.4
libnetcdf: 4.6.2
xarray: 0.11.3
pandas: 0.24.2
numpy: 1.15.4
scipy: 1.2.1
netCDF4: 1.4.3.2
pydap: None
h5netcdf: None
h5py: 2.9.0
Nio: 1.5.5
zarr: None
cftime: 1.0.3.4
PseudonetCDF: None
rasterio: 1.0.21
cfgrib: None
iris: 2.2.0
bottleneck: None
cyordereddict: None
dask: 1.1.4
distributed: 1.26.0
matplotlib: 3.0.2
cartopy: 0.17.0
seaborn: 0.9.0
setuptools: 40.8.0
pip: 19.0.3
conda: 4.6.8
pytest: 4.3.1
IPython: 7.3.0
sphinx: None