-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
Is your feature request related to a problem?
Currently if you want to set an xindex on a coord that already has an index you have to remember the slightly differently named drop_indexes and to write out all the coord names twice.
da = xr.DataArray([0,1,2,3], dims=('x'), coords={'x': np.linspace(0,1,4)})
# need to repeat all the variables
da.drop_indexes('x').set_xindex('x', CustomIndex)
# ValueError: those coordinates already have an index: {'x'}
da.set_xindex('x', CustomIndex)Describe the solution you'd like
Give set_xindex a drop_existing argument (default to False) that automatically drops whatever is necessary to complete the index setting the user requested.
Describe alternatives you've considered
No response
Additional context
No response