Skip to content

CFTimeIndex changes to normal Index after renaming #3522

Description

@ahuang11

MCVE Code Sample

Since this code crashes for me and I don't have xarray master, I can't create a tested MCVE Code sample at the moment, but I think something along the lines of:

import xarray as xr
ds = xr.Dataset(coords={'time': xr.cftime_range(start='2000', periods=6, freq='2MS', calendar='noleap'), 'something': [0, 1, 2, 3]})
print(ds.indexes['time'])
ds = ds.rename({'something': 'something_else'})
print(ds.indexes['time'])

Expected Output

CFTimeIndex([2000-05-01 12:00:00, 2000-05-02 12:00:00,
             ...
             2001-04-01 12:00:00],
            dtype='object', name='time', length=425)

After renaming

Index([2000-05-01 12:00:00, 2000-05-02 12:00:00,
             ...
             2001-04-01 12:00:00],
            dtype='object', name='time', length=425)

Problem Description

CFTimeIndex changes to normal Index after renaming

Output of xr.show_versions()

Details

xarray: 0.14.0
pandas: 0.25.2
numpy: 1.17.2
scipy: 1.3.1
netCDF4: 1.5.3
pydap: None
h5netcdf: 0.7.4
h5py: 2.9.0
Nio: None
zarr: None
cftime: 1.0.4.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.1.0
cfgrib: None
iris: None
bottleneck: 1.2.1
dask: 2.6.0
distributed: 2.6.0
matplotlib: 3.1.1
cartopy: 0.17.0
seaborn: None
numbagg: None
setuptools: 41.4.0
pip: 19.3.1
conda: None
pytest: 5.2.1
IPython: 7.9.0
sphinx: None

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions