issues: 155637074
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
155637074 | MDU6SXNzdWUxNTU2MzcwNzQ= | 850 | multi-index panel to xrarray dataarray index selection | 5911007 | closed | 0 | 4 | 2016-05-19T01:36:35Z | 2016-08-11T04:22:40Z | 2016-08-11T04:22:40Z | NONE | I am playing with xarray (moving away from pandas panel) but I cannot get my head around the following example. I create a multiindex panel and then convert it to a dataarray. I would like then to slice as I used to do in pandas , but trying the equivalent it fails with Similarly I cannot get x.sel(major_axis=?) to work trying to achieve the same result. ``` import numpy as np import pandas as pd import xarray as xr columns=['A','B','C'] index=pd.MultiIndex.from_product([['a','b','c','d'],[1,2,3]]) items=['x','y','z'] z=pd.Panel.from_dict({i:pd.DataFrame(data=np.random.rand(12,3),index=index,columns=columns) for i in items}) z.loc[:,(slice(None),[3]),'A'] #<-- That's what I want to do in xarray x=z.to_xarray() x.loc[:,(slice(None),[3]),'A'] #<- It fails ``` Do you have any insight? |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/850/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |