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/6256#issuecomment-1047241508,https://api.github.com/repos/pydata/xarray/issues/6256,1047241508,IC_kwDOAMm_X84-a6Mk,4160723,2022-02-21T21:28:56Z,2022-02-21T21:28:56Z,MEMBER,"This is still the same behavior with #5692. We would need to handle `pd.RangeIndex` (and perhaps `range`?) label indexers similarly to `slice` label indexers, i.e., use `pd.Index.slice_indexer` internally to return integer indexers as slices (*). ```python b = my_da.sel(time=slice(0, 2)) b.get_index('time') # RangeIndex(start=0, stop=3, step=1, name='time') ``` Otherwise, label indexers get internally converted to arrays. Note that the conversion to an `Int64Index` is done in pandas (nothing specific is done on the Xarray side), so I expect that this will be eventually addressed in pandas. This conversion may not be too problematic if we consider this as an implementation detail (although I might be missing some important aspect). ```python idx = pd.RangeIndex(0, 100) idx[slice(0, 3)] # RangeIndex(start=0, stop=3, step=1) idx[[0, 1, 2]] # Int64Index([0, 1, 2], dtype='int64') ``` (*) One major difference is that in Xarray `slice` label indexers are upper-bound inclusive, while `pd.RangeIndex` and `range` are not!","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1128304139