add drop_existing kwarg to set_xindex#11008
Conversation
drop_existing kwarg to set_xindex
benbovy
left a comment
There was a problem hiding this comment.
Thanks @ianhi, I think that this is a convenient addition!
I'd just rename drop_existing to simply drop. The latter is a bit less self-explanatory but more consistent with the rest of the Xarray API where drop is already a parameter of many methods like .reset_index, .reset_coords, .isel, .where, etc.
|
just to confirm — and I left a comment at #11007, so possibly folks saw this — we're sure this shouldn't replace by default? currently the closest function is |
I don't have strong opinions on this, we could replace it by default indeed. It might break the workflow of some users who rely on explicit-only index replacement as a safety guard, however to my knowledge people are actually rather annoyed by that (including me :-)). |
|
re the default I was defaulting to being cautious given xarray's large userbase. But I think it's in general a large user base, perhaps not for this specific function. I agree that a default of |
Yes I think we are! |
|
(this might be going too far, but we may not even need the |
Agreed! In most (in not all) Xarray API methods mentioned above with a The initial and only reason for not automatically dropping existing indexes in |
|
I have removed the kwarg entirely. this is now the default and only behavior. |
drop_existingtoset_xindex#11007whats-new.rstapi.rst