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() orda.to_dataframe("A") ``` Problem descriptionWhen 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
Output of
|
{
"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 |