Skip to content

BUG: DataFrame.drop fails when columns argument given tuple #43985

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

Closed
wants to merge 3 commits into from
Closed

BUG: DataFrame.drop fails when columns argument given tuple #43985

wants to merge 3 commits into from

Conversation

erfannariman
Copy link
Member

labels = list(labels)
else:
labels = [labels]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this change behavior for tuple column names?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, fails indeed, added test for it, will try to resolve.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it is resolvable - if you sometimes treat a tuple as a label and sometimes unpack as a list, seems like there would be unavoidable ambiguities? Would be more inclined to say the behavior is correct as is, but haven't thought about it too much

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point and there probably is some ambiguity since we can also use tuples to drop MultiIndex. I can revert the changes and just add a test that the described case always raises.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds great, thanks!

@erfannariman erfannariman marked this pull request as draft October 11, 2021 22:13
@attack68
Copy link
Contributor

I dont like allowing tuples as sequence input. See: #42329 (comment)

@jreback jreback added the Indexing Related to indexing on series/frames, not to indexes themselves label Oct 21, 2021
@erfannariman
Copy link
Member Author

Closed this for now since it is not clear how to proceed and there is ambiguity around using tuples for indexing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: DataFrame.drop() fails when columns= is given as tuple
4 participants