Feature Type
-
[ ] Adding new functionality to pandas
-
[x] Changing existing functionality in pandas
-
[ ] Removing existing functionality in pandas
Problem Description
Feature Description
can we make the pandas function consistent in how they raise errors drop should be default to ignore and not likely to break.
Alternative Solutions
def drop(labels=None, axis=0, index=None, columns=None, Level=None, inplace=false, errors='ignore'):
Additional Context
No response
Comment From: Gwalib
Hello!! Well, I noticed that, this leads to unexpected errors for users when dropping non-existent columns or index labels, even though renaming silently skips missing keys.
We can either change the default:
i.e. errors='raise'
to errors='ignore'
in DataFrame.drop()
:
Or we can add a warning, if this causes inconsistency.
I would like to work on this issue! Let me know if it’s okay for me to work on it, and whether changing the default behavior of errors
in DataFrame.drop()
is acceptable from a compatibility perspective.
Comment From: petern48
I prefer to set rename's default to errors="raise" instead. I was debugging my code for a while with zero idea that the problem was in rename. When I set errors="raise"
manually, it instantly made it clear that the bug was that I was using rename incorrectly. I made the same mistake as the issue I tagged above, where I didn't specify "columns" in the arguments, so it was silently trying to rename indexes without telling me. I feel like it's a very easy to make that mistake since it's feels more natural to rename columns instead of indexes.