issues: 672662079
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
672662079 | MDU6SXNzdWU2NzI2NjIwNzk= | 4306 | Indexing datetime broken with pandas 1.1.0 | 2405019 | closed | 0 | 2 | 2020-08-04T09:50:59Z | 2020-08-04T09:54:46Z | 2020-08-04T09:54:46Z | CONTRIBUTOR | Code below works with ```python import pandas as pd import xarray as xr import numpy as np dates = pd.date_range("2000-01-01", periods=5) ds = xr.Dataset(coords=dict(dates=dates)) ds['v'] = ("dates"), np.arange(ds.dates.count()) ds.sel(dates=ds.dates.values[2]) ``` The `.sel` operation produces a KeyError in `pandas/core/indexes/datetimes.py`:Traceback (most recent call last): File "datetime_problem.py", line 11, in <module> ds.sel(dates=ds.dates.values[2]) File "/Users/leifdenby/miniconda3/envs/lagtraj/lib/python3.8/site-packages/xarray/core/dataset.py", line 2101, in sel pos_indexers, new_indexes = remap_label_indexers( File "/Users/leifdenby/miniconda3/envs/lagtraj/lib/python3.8/site-packages/xarray/core/coordinates.py", line 396, in remap_label_indexers pos_indexers, new_indexes = indexing.remap_label_indexers( File "/Users/leifdenby/miniconda3/envs/lagtraj/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 "/Users/leifdenby/miniconda3/envs/lagtraj/lib/python3.8/site-packages/xarray/core/indexing.py", line 189, in convert_label_indexer indexer = index.get_loc( File "/Users/leifdenby/miniconda3/envs/lagtraj/lib/python3.8/site-packages/pandas/core/indexes/datetimes.py", line 622, in get_loc raise KeyError(key) KeyError: 946857600000000000 Environment: Output of <tt>xr.show_versions()</tt>INSTALLED VERSIONS ------------------ commit: None python: 3.8.5 | packaged by conda-forge | (default, Jul 24 2020, 01:06:20) [Clang 10.0.1 ] python-bits: 64 OS: Darwin OS-release: 18.0.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: en_GB.UTF-8 LANG: None LOCALE: en_GB.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.6.3 xarray: 0.16.0 pandas: 1.1.0 numpy: 1.19.1 scipy: 1.5.2 netCDF4: 1.5.4 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.2.1 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.22.0 distributed: None matplotlib: 3.3.0 cartopy: None seaborn: None numbagg: None pint: None setuptools: 49.2.0.post20200712 pip: 20.1.1 conda: None pytest: 6.0.1 IPython: 7.16.1 sphinx: NoneApologies if this is a know issue. I tried to work out whether this is an issue with pandas or xarray (I assume it is with pandas), but couldn't find the right piece of code. Happy to fix the issue if someone could show me what needs to change. |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/4306/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |