You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I seem to be having the same issue that was reported here: #1932, after upgrading pandas to 1.1.0. The error does not arise with pandas 1.0.3.
Example: import xarray as ds = xr.tutorial.load_dataset('air_temperature') da = ds.air da.sel(time=da.time[0])
Result is:
`---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
in
----> 1 da.sel(time=da.time[0])
2 #da.time
I seem to be having the same issue that was reported here: #1932, after upgrading pandas to 1.1.0. The error does not arise with pandas 1.0.3.
Example:
import xarray as
ds = xr.tutorial.load_dataset('air_temperature')
da = ds.air
da.sel(time=da.time[0])
Result is:
`---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
in
----> 1 da.sel(time=da.time[0])
2 #da.time
~/miniconda3/envs/ats641/lib/python3.7/site-packages/xarray/core/dataarray.py in sel(self, indexers, method, tolerance, drop, **indexers_kwargs)
1152 method=method,
1153 tolerance=tolerance,
-> 1154 **indexers_kwargs,
1155 )
1156 return self._from_temp_dataset(ds)
~/miniconda3/envs/ats641/lib/python3.7/site-packages/xarray/core/dataset.py in sel(self, indexers, method, tolerance, drop, **indexers_kwargs)
2100 indexers = either_dict_or_kwargs(indexers, indexers_kwargs, "sel")
2101 pos_indexers, new_indexes = remap_label_indexers(
-> 2102 self, indexers=indexers, method=method, tolerance=tolerance
2103 )
2104 result = self.isel(indexers=pos_indexers, drop=drop)
~/miniconda3/envs/ats641/lib/python3.7/site-packages/xarray/core/coordinates.py in remap_label_indexers(obj, indexers, method, tolerance, **indexers_kwargs)
395
396 pos_indexers, new_indexes = indexing.remap_label_indexers(
--> 397 obj, v_indexers, method=method, tolerance=tolerance
398 )
399 # attach indexer's coordinate to pos_indexers
~/miniconda3/envs/ats641/lib/python3.7/site-packages/xarray/core/indexing.py in remap_label_indexers(data_obj, indexers, method, tolerance)
268 coords_dtype = data_obj.coords[dim].dtype
269 label = maybe_cast_to_coords_dtype(label, coords_dtype)
--> 270 idxr, new_idx = convert_label_indexer(index, label, dim, method, tolerance)
271 pos_indexers[dim] = idxr
272 if new_idx is not None:
~/miniconda3/envs/ats641/lib/python3.7/site-packages/xarray/core/indexing.py in convert_label_indexer(index, label, index_name, method, tolerance)
188 else:
189 indexer = index.get_loc(
--> 190 label.item(), method=method, tolerance=tolerance
191 )
192 elif label.dtype.kind == "b":
~/miniconda3/envs/ats641/lib/python3.7/site-packages/pandas/core/indexes/datetimes.py in get_loc(self, key, method, tolerance)
620 else:
621 # unrecognized type
--> 622 raise KeyError(key)
623
624 try:
KeyError: 1356998400000000000`
Output of xr.show_versions() is:
`
INSTALLED VERSIONS
commit: None
python: 3.7.6 | packaged by conda-forge | (default, Jan 7 2020, 22:05:27)
[Clang 9.0.1 ]
python-bits: 64
OS: Darwin
OS-release: 19.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.7.3
xarray: 0.16.0
pandas: 1.1.0
numpy: 1.18.1
scipy: 1.5.2
netCDF4: 1.5.3
pydap: None
h5netcdf: None
h5py: None
Nio: 1.5.5
zarr: None
cftime: 1.2.1
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: 0.9.8.3
iris: None
bottleneck: None
dask: 2.20.0
distributed: None
matplotlib: 3.1.3
cartopy: 0.17.0
seaborn: 0.10.1
numbagg: None
pint: 0.15
setuptools: 49.6.0.post20200814
pip: 20.0.2
conda: None
pytest: None
IPython: 7.17.0
sphinx: None
`
With pandas 1.0.3, da.sel(time=da.time[0]) works correctly and returns a slice.
Thanks for any help you can offer!
The text was updated successfully, but these errors were encountered: