Skip to content

Conversation

khemkaran10
Copy link
Contributor

@khemkaran10 khemkaran10 commented Jul 14, 2025

@khemkaran10
Copy link
Contributor 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
Contributor 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).

@jbrockmendel
Copy link
Member

LGTM cc @rhshadrach

@rhshadrach rhshadrach changed the title FIX BUG: If both index and axis are passed to drop(), it will raise ValueError with clear message. BUG: If both index and axis are passed to DataFrame.drop, raise a clear error Jul 18, 2025
@rhshadrach rhshadrach added Bug Error Reporting Incorrect or improved errors from pandas labels Jul 18, 2025
@rhshadrach rhshadrach merged commit 6a6a1ba into pandas-dev:main Jul 18, 2025
51 checks passed
@rhshadrach
Copy link
Member

Thanks @khemkaran10!

eicchen pushed a commit to eicchen/pandas that referenced this pull request Aug 19, 2025
…ar error (pandas-dev#61855)

Co-authored-by: Khemkaran <sunny@Khemkaran-MacBook-Pro.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: drop doesn't recognise MultiIndexes
4 participants