-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
.sel return errors when using floats for no apparent reason #7108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Generally this is because the floats aren't exactly the same value — does passing |
Returned the following:
|
Ah, right. Does it select a value with just Float indexes are often a source of pain, unfortunately! |
It looks like the error is because of the non-monotonic coordinate labels for the "lon" coordinate in When a |
Pandas docs seem stricter than the implementation. From this snippet from pandas source code monotonicity is only required after My concern with checking first is that code like below will stop working (if I understand correctly). Is has unique but (alphabetically) unsorted coords (although its order may have meaning for the user). I regularly select a slice by specifying the labels corresponding to the first and last elements I want to extract. I would suggest in this case to just try while catching any
|
...also for my ability to know what's going on, apparently :). Thanks a lot @benbovy . Yes, that would be great to raise a more informative error. We could also put an issue in upstream if pandas itself has the same issue. |
TBH, I had to do some research before figuring out what was going on :). |
The values in And to answer earlier comments, Thanks for your help and your time. |
A custom Xarray index would help, e.g., |
Thanks, it finally worked. |
What happened?
Using floats
.sel()
on different datasets from the same provider trigger an error. Despite the fact that the concerneddims
are all infloat32
type (see log).Attempts with default
float
,numpy.float32()
andnumpy.float64()
gave the same output.What did you expect to happen?
Normal behavior of
.sel()
.Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
The data are provided by JAXA P-Tree.
Environment
INSTALLED VERSIONS
commit: None
python: 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:50:36) [MSC v.1929 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en
LOCALE: ('English_New Zealand', '1252')
libhdf5: 1.12.1
libnetcdf: 4.8.1
xarray: 2022.6.0
pandas: 1.5.0
numpy: 1.23.3
scipy: 1.9.1
netCDF4: 1.6.0
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: 1.6.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2022.9.1
distributed: None
matplotlib: 3.5.2
cartopy: 0.20.2
seaborn: None
numbagg: None
fsspec: 2022.8.2
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 65.3.0
pip: 22.2.2
conda: None
pytest: None
IPython: 8.5.0
sphinx: 5.2.1
The text was updated successfully, but these errors were encountered: