home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 454106835

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
454106835 MDU6SXNzdWU0NTQxMDY4MzU= 3008 to_dataframe/to_series fails when one out of more than one dims are stacked / multiindex 2195071 closed 0     3 2019-06-10T10:39:22Z 2021-02-20T00:08:42Z 2021-02-20T00:08:42Z NONE      

Code Sample, a copy-pastable example if possible

```python 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

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 python da.isel(c=0).to_series()

Output of xr.show_versions()

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.1 xarray: 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
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3008/reactions",
    "total_count": 3,
    "+1": 3,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 3 rows from issue in issue_comments
Powered by Datasette · Queries took 0.689ms · About: xarray-datasette