-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
xarray .count() gives -1 when it should be 1? #2770
Comments
Thanks for the issue @ru111 That does seem weird. Do you have a minimally reproducible example? |
I can reproduce OP when the coordinate is a datetime64, but the problem does not occur with int64s (or float64s). datetime coordinate:
int coordinate:
|
The problem seems to come up for scalar
|
Apparently xarray/xarray/core/duck_array_ops.py Line 188 in 4cd56a9
To fix this, we should either switch |
Though for datetime64 we should use ~np.nat? |
BUG: Fix pydata#2770 by changing ~ to np.logical_not() TST: Add test for scalar datetime64 value DOC: Add to whats-new.rst
BUG: Fix #2770 by changing ~ to np.logical_not() TST: Add test for scalar datetime64 value DOC: Add to whats-new.rst
Data array
da
I'm working with looks like:Now
int(da.time.count())
gives 365 which is correct. However when I select a time coordinateda2 = da.isel(time=0)
the resulting array has one time coordinate:and
int(da2.time.count())
gives me -1 instead of 1. I wasn't sure if this was a bug or I wasn't selecting the coordinate properly - if this is the case how should I call the time coordinate to count it correctly?The text was updated successfully, but these errors were encountered: