home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 255597950

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
255597950 MDU6SXNzdWUyNTU1OTc5NTA= 1554 TypeError on DataArray.stack() if any of the dimensions to be stacked has a MultiIndex 25231875 open 0     3 2017-09-06T13:09:30Z 2019-04-05T18:35:12Z   NONE      

If I call .stack() on a DataArray, and any of the dimensions to be stacked already has a MultiIndex on it, I get an error:

TypeError: Must pass list-like as `names`.

Maybe it doesn't make sense for .stack() to work on an existing MultiIndex, but that should probably be documented, and perhaps throw a more informative error.

Here's the full trace:

``` Traceback (most recent call last) <ipython-input-6-ce81ac38d71e> in <module>() ----> 1 xr_one_flat_stacked = xr_one_flat.stack(alphanumeric=("letters", "numbers")) 2 xr_one_flat_stacked

/Users/jjpr/anaconda/envs/dldata/lib/python2.7/site-packages/xarray/core/dataarray.pyc in stack(self, dimensions) 1027 DataArray.unstack 1028 """ -> 1029 ds = self._to_temp_dataset().stack(dimensions) 1030 return self._from_temp_dataset(ds) 1031

/Users/jjpr/anaconda/envs/dldata/lib/python2.7/site-packages/xarray/core/dataset.pyc in stack(self, **dimensions) 1832 result = self 1833 for new_dim, dims in dimensions.items(): -> 1834 result = result._stack_once(dims, new_dim) 1835 return result 1836

/Users/jjpr/anaconda/envs/dldata/lib/python2.7/site-packages/xarray/core/dataset.pyc in _stack_once(self, dims, new_dim) 1801 else level 1802 for level in levels] -> 1803 idx = utils.multiindex_from_product_levels(levels, names=dims) 1804 variables[new_dim] = IndexVariable(new_dim, idx) 1805

/Users/jjpr/anaconda/envs/dldata/lib/python2.7/site-packages/xarray/core/utils.pyc in multiindex_from_product_levels(levels, names) 79 indexing='ij') 80 labels = [x.ravel() for x in labels_mesh] ---> 81 return pd.MultiIndex(levels, labels, sortorder=0, names=names) 82 83

/Users/jjpr/anaconda/envs/dldata/lib/python2.7/site-packages/pandas/indexes/multi.pyc in new(cls, levels, labels, sortorder, names, copy, verify_integrity, _set_identity, name, **kwargs) 103 if names is not None: 104 # handles name validation --> 105 result._set_names(names) 106 107 if sortorder is not None:

/Users/jjpr/anaconda/envs/dldata/lib/python2.7/site-packages/pandas/indexes/multi.pyc in _set_names(self, names, level, validate) 505 # set the name 506 for l, name in zip(level, names): --> 507 self.levels[l].rename(name, inplace=True) 508 509 names = property(fset=_set_names, fget=_get_names,

/Users/jjpr/anaconda/envs/dldata/lib/python2.7/site-packages/pandas/indexes/base.pyc in set_names(self, names, level, inplace) 997 998 if not is_list_like(names) and level is None and self.nlevels > 1: --> 999 raise TypeError("Must pass list-like as names.") 1000 1001 if not is_list_like(names):

TypeError: Must pass list-like as names. ```

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1554/reactions",
    "total_count": 3,
    "+1": 3,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

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