issue_comments: 1239412326
This data as json
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/6838#issuecomment-1239412326 | https://api.github.com/repos/pydata/xarray/issues/6838 | 1239412326 | IC_kwDOAMm_X85J3-5m | 4160723 | 2022-09-07T13:45:25Z | 2022-09-07T13:45:25Z | MEMBER |
I'm working on this issue right now and I see this too. I don't think that providing slice objects to multi-index level coordinates in ```python da <xarray.DataArray (x: 4)>array([0.30120807, 0.43951659, 0.19163508, 0.57251755])Coordinates:* x (x) object MultiIndex* y (x) float64 0.0 0.3333 0.6667 1.0* z (x) int64 4 5 6 7da.sel(z=[4, 5]) ValueError: Vectorized selection is not available along coordinate 'z' (multi-index level)``` The fact that it used to work with slices looks like a side effect. For example, providing a slice for only one of the level coordinates drops that coordinate in the resulting dataset (v2022.3.0): ```python da.sel(y=slice(None, 0.5)) <xarray.DataArray (z: 2)>array([0.4004091 , 0.11179854])Coordinates:* z (z) int64 4 5The 'y' coord is missing! It should be still there.``` I think that we could support slices in a clean way (maybe any sequence of values too?) by reusing ```python note the difference betweenda.sel(y=0.0, z=slice(None)) <xarray.DataArray (x: 1)>array([0.08696024])Coordinates:* x (x) object MultiIndex* y (x) float64 0.0* z (x) int64 4andda.sel(y=0.0) <xarray.DataArray (z: 1)>array([0.08696024])Coordinates:* z (z) int64 4y float64 0.0the 1st one calls pandas.MultiIndex.get_locs, whilethe 2nd one calls pandas.MultiIndex.get_loc_level``` |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1319724885 |