Skip to content

FIX BUG: If both index and axis are passed to drop(), it will raise ValueError with clear message. #61855

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

khemkaran10
Copy link

@khemkaran10 khemkaran10 commented Jul 14, 2025

@khemkaran10
Copy link
Author

pre-commit.ci autofix

@khemkaran10 khemkaran10 changed the title Both index and axis are passed to drop() it will raise a better error FIX BUG: If both index and axis are passed to drop(), it will raise ValueError with clear message. Jul 14, 2025
@khemkaran10
Copy link
Author

@camriddell I have made the changes.

@camriddell
Copy link

camriddell commented Jul 15, 2025

Can @rhshadrach take a look and provide some guidance? If we want to maintain backwards compat. then this is likely the final form of this PR.

However there is a deeper issue that is not present in either (thanks for finding these @khemkaran10) DataFrame.reindex, DataFrame.rename. Namely, those methods have a default of axis=None and can therefore check when that value is passed, whereas in .drop the axis argument defaults to axis=0 thus making it always "set". So we can check for axis==1 as @khemkaran10 did in the PR (or axis != 0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: drop doesn't recognise MultiIndexes
3 participants