-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Code Sample, a copy-pastable example if possible
da = xr.DataArray([[[1]]], dims=["a","b","c"]).stack(ab=["a", "b"])
da.to_series()
# or
da.to_dataframe("A")Problem description
When a dataarray has one multiindex dimension, as produced by stack, and has other dimesnions as well, to_series fails to create an combined multiindex.
I would expect a series/dataframe with a multiindex with names a,b,c. Instead I get
Details
lib/python2.7/site-packages/pandas/core/dtypes/missing.pyc in _isna_new(obj) 115 # hack (for now) because MI registers as ndarray 116 elif isinstance(obj, ABCMultiIndex): --> 117 raise NotImplementedError("isna is not defined for MultiIndex") 118 elif isinstance(obj, (ABCSeries, np.ndarray, ABCIndexClass, 119 ABCExtensionArray)):NotImplementedError: isna is not defined for MultiIndex
On the other hand, when there is only one dimension, which is stacked, to_series and to_dataframe work
da.isel(c=0).to_series()Output of xr.show_versions()
Details
INSTALLED VERSIONS ------------------ commit: None python: 2.7.15 |Anaconda, Inc.| (default, May 1 2018, 23:32:55) [GCC 7.2.0] python-bits: 64 OS: Linux OS-release: 3.13.0-48-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: None.None libhdf5: 1.8.17 libnetcdf: 4.4.1xarray: 0.11.3
pandas: 0.23.4
numpy: 1.12.1
scipy: 0.19.1
netCDF4: 1.2.8
pydap: None
h5netcdf: None
h5py: 2.6.0
Nio: None
zarr: None
cftime: None
PseudonetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.2.0
cyordereddict: None
dask: 0.17.3
distributed: 1.21.0
matplotlib: 2.2.2
cartopy: None
seaborn: 0.7.1
setuptools: 0.6
pip: 19.0.1
conda: None
pytest: 3.0.5
IPython: 5.8.0
sphinx: 1.5.1