html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/1408#issuecomment-919974416,https://api.github.com/repos/pydata/xarray/issues/1408,919974416,IC_kwDOAMm_X8421bIQ,4160723,2021-09-15T12:27:34Z,2021-09-15T12:27:34Z,MEMBER,"@fujiisoup the behavior that you expect has been implemented in #5692 (I still need to fix/update the tests): ```python >>> ds.sel(x=2) Dimensions: (y: 2) Coordinates: * y (y) >> ds.isel(yx=0) Dimensions: () Coordinates: yx object ('a', 1) y I'm just wondering if it really makes sense to keep a MultiIndex for a coordinate that is not a dimension anymore like in this case. And this is just a nonsense :) Sorry it is late! Yep I agree it would be nice to have scalar coordinates in both cases. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,228295383 https://github.com/pydata/xarray/issues/1408#issuecomment-301353831,https://api.github.com/repos/pydata/xarray/issues/1408,301353831,MDEyOklzc3VlQ29tbWVudDMwMTM1MzgzMQ==,6815844,2017-05-15T01:10:25Z,2017-05-15T01:10:25Z,MEMBER,"@benbovy Thanks for the comment. Actually, I expected the following behavior ```python In [1]: ds.sel(x=2) Out[1]: Dimensions: (y: 2) Coordinates: * y (y) object 'a' 'b' x int64 2 Data variables: foo (y) int64 2 5 ``` where the selected `x` is automatically converted to a scalar coordinate. And also for the second issue, I expected something like ```python In [2]: ds.isel(yx=0) Out[2]: Dimensions: () Coordinates: y Dimensions: (yx: 2) Coordinates: * yx MultiIndex - y (yx) object 'a' 'b' - x (yx) int64 2 2 Data variables: foo (yx) int64 2 5 ``` and ```python In [5]: ds.sel(x=2) Out[5]: Dimensions: (y: 2) Coordinates: * y (y) object 'a' 'b' x (y) int64 2 2 Data variables: foo (y) int64 2 5 ``` --- The second issue is also due to how MultiIndex works in pandas: ```python In [10]: midx[0] Out[10]: ('a', 1) In [11]: midx[[0, 1]] Out[11]: MultiIndex(levels=[['a', 'b'], [1, 2, 3]], labels=[[0, 0], [0, 1]], names=['y', 'x']) ``` I'm just wondering if it really makes sense to keep a MultiIndex for a coordinate that is not a dimension anymore like in this case. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,228295383 https://github.com/pydata/xarray/issues/1408#issuecomment-301303055,https://api.github.com/repos/pydata/xarray/issues/1408,301303055,MDEyOklzc3VlQ29tbWVudDMwMTMwMzA1NQ==,6815844,2017-05-14T10:19:15Z,2017-05-14T10:19:15Z,MEMBER,"@shoyer Thanks for the information. (Sorry for my inaccurate ipython output) Another related issue is ```python In[3]: ds.isel(yx=1) Out[3]: Dimensions: () Coordinates: yx object ('a', 1) Data variables: foo int64 1 ``` where MultiIndex structure is totally gone. (`ds.isel(yx=[0, 1])` works perfectly.) I am now looking into the code. Do you guys have any idea to fix them? I am thinking to modify [Index.remap_label_indexers](https://github.com/pydata/xarray/blob/master/xarray/core/indexing.py#L266) so that it also returns `selected_dims` containing names of dims that should be converted to scalar coordinates. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,228295383 https://github.com/pydata/xarray/issues/1408#issuecomment-301218692,https://api.github.com/repos/pydata/xarray/issues/1408,301218692,MDEyOklzc3VlQ29tbWVudDMwMTIxODY5Mg==,1217238,2017-05-13T02:02:38Z,2017-05-13T02:02:38Z,MEMBER,"No, I don't think this was intentional/desired, though it might be slightly tricky to fix this with the current code structure. @benbovy any thoughts? For reference: ```python In [4]: ds Out[4]: Dimensions: (yx: 6) Coordinates: * yx (yx) MultiIndex - y (yx) object 'a' 'a' 'a' 'b' 'b' 'b' - x (yx) int64 1 2 3 1 2 3 Data variables: foo (yx) int64 1 2 3 4 5 6 In [5]: ds.sel(x=2) Out[5]: Dimensions: (y: 2) Coordinates: * y (y) object 'a' 'b' Data variables: foo (y) int64 2 5 ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,228295383