swap_dims()
incorrectly changes underlying index name
#3748
Labels
swap_dims()
incorrectly changes underlying index name
#3748
MCVE Code Sample
The dimension name is appropriately swapped but the pandas index name is incorrect.
Expected Output
Problem Description
This is a problem because running
x.swap_dims({"idx": "y"}).to_dataframe()
givesa dataframe with columns
["x", "idx"]
and index"idx"
. This gives ambiguous names and drops the original name, while the DataArray string representation gives no indication that this might be happening.Output of
xr.show_versions()
xarray: 0.15.0
pandas: 0.25.3
numpy: 1.18.1
scipy: 1.4.1
netCDF4: 1.5.3
pydap: None
h5netcdf: None
h5py: 2.10.0
Nio: None
zarr: None
cftime: 1.0.4.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2.10.1
distributed: 2.10.0
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
setuptools: 45.1.0.post20200119
pip: 20.0.2
conda: None
pytest: 5.3.5
IPython: 7.12.0
sphinx: None
The text was updated successfully, but these errors were encountered: