-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
DataArray.drop_isel / .drop_sel with duplicated initial time stamp - InvalidIndexError #6605
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
Labels
Comments
Can you try drop_duplicates please? |
This works, thanks. |
Thanks this looks like a bug to me. da = xr.DataArray(np.ones(5), dims="x", coords={"x": np.array([1, 2, 2, 3, 4])})
ds.sel(x=2) # works
ds.isel(x=2) # works
da.drop_isel(x=2) # error I think the issue is we should not treat unindexed dims the same as an indexed dim.
Also |
Great find @dcherian ! |
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is your issue?
I have a DataArray
ds
with 7098 time steps in cftime format. One of these time steps is a duplicate (pos: 7087 & 7088).I tried to drop the first instance using both
ds.drop_isel(time=[7087])
andds.drop_sel(ds.time[7087])
but get the error:pandas.errors.InvalidIndexError: Reindexing only valid with uniquely valued Index objects
.The method works if I do not have the duplicate in it. Maybe this is the wrong method in the first place but it seemed to be the way to go. I am confused on how to get rid of the duplicate, and, if the method is the correct method, if this might be an issue.
The text was updated successfully, but these errors were encountered: