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/1240#issuecomment-682435326,https://api.github.com/repos/pydata/xarray/issues/1240,682435326,MDEyOklzc3VlQ29tbWVudDY4MjQzNTMyNg==,500246,2020-08-28T09:48:18Z,2020-08-28T09:48:56Z,CONTRIBUTOR,"I fixed my conda environment now (something was wrong as I appeared to have two xarray installations in parallel). I still get the `KeyError` with latest xarray master and latest pandas master: ``` $ conda list | egrep -w '(pandas|xarray)' pandas 1.2.0.dev0+167.g1f35b0621 pypi_0 pypi xarray 0.16.1.dev65+g13caf96e pypi_0 pypi $ python mwe83.py Traceback (most recent call last): File ""mwe83.py"", line 5, in da.sel(time=da.coords[""time""][0]) File ""/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/xarray/core/dataarray.py"", line 1142, in sel ds = self._to_temp_dataset().sel( File ""/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/xarray/core/dataset.py"", line 2096, in sel pos_indexers, new_indexes = remap_label_indexers( File ""/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/xarray/core/coordinates.py"", line 395, in remap_label_indexers pos_indexers, new_indexes = indexing.remap_label_indexers( File ""/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/xarray/core/indexing.py"", line 270, in remap_label_indexers idxr, new_idx = convert_label_indexer(index, label, dim, method, tolerance) File ""/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/xarray/core/indexing.py"", line 189, in convert_label_indexer indexer = index.get_loc( File ""/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/pandas/core/indexes/datetimes.py"", line 622, in get_loc raise KeyError(key) KeyError: 0 $ cat mwe83.py import xarray as xr import numpy as np da = xr.DataArray([0, 1], dims=(""time"",), coords={""time"": np.array([0, 1], dtype=""M8[s]"")}) da.sel(time=slice(da.coords[""time""][0], da.coords[""time""][1])) da.sel(time=da.coords[""time""][0]) ``` Oops, by ""already have"" you meant it's already been reported, I thought you meant it had already been fixed. All clear then. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,204071440 https://github.com/pydata/xarray/issues/1240#issuecomment-682393298,https://api.github.com/repos/pydata/xarray/issues/1240,682393298,MDEyOklzc3VlQ29tbWVudDY4MjM5MzI5OA==,500246,2020-08-28T08:14:26Z,2020-08-28T08:14:26Z,CONTRIBUTOR,"This was closed and was solved for slicing, but not for element indexing: ```python import xarray as xr import numpy as np da = xr.DataArray([0, 1], dims=(""time"",), coords={""time"": np.array([0, 1], dtype=""M8[s]"")}) da.sel(time=da.coords[""time""][0]) ``` results in ``` Traceback (most recent call last): File ""mwe83.py"", line 4, in da.sel(time=da.coords[""time""][0]) File ""/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/xarray/core/dataarray.py"", line 1142, in sel ds = self._to_temp_dataset().sel( File ""/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/xarray/core/dataset.py"", line 2096, in sel pos_indexers, new_indexes = remap_label_indexers( File ""/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/xarray/core/coordinates.py"", line 395, in remap_label_indexers pos_indexers, new_indexes = indexing.remap_label_indexers( File ""/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/xarray/core/indexing.py"", line 270, in remap_label_indexers idxr, new_idx = convert_label_indexer(index, label, dim, method, tolerance) File ""/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/xarray/core/indexing.py"", line 189, in convert_label_indexer indexer = index.get_loc( File ""/data/gholl/miniconda3/envs/py38/lib/python3.8/site-packages/pandas/core/indexes/datetimes.py"", line 622, in get_loc raise KeyError(key) KeyError: 0 ``` using xarray 0.15.2.dev64+g2542a63f (latest master). I think it would be desirable that it works in both cases. Should we reopen this issue or should I open a new?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,204071440