Skip to content
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

fix: #1008 columns in DataFrame.drop #1131

Merged

Conversation

cmp0xff
Copy link
Contributor

@cmp0xff cmp0xff commented Feb 26, 2025

check(assert_type(df.drop([0]), pd.DataFrame), pd.DataFrame)
check(assert_type(df.drop(index=[0]), pd.DataFrame), pd.DataFrame)
check(assert_type(df.drop(columns=["col1"]), pd.DataFrame), pd.DataFrame)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed since it duplicates L346 above

@@ -344,9 +344,9 @@ def test_types_drop() -> None:
df = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
check(assert_type(df.drop("col1", axis=1), pd.DataFrame), pd.DataFrame)
check(assert_type(df.drop(columns=["col1"]), pd.DataFrame), pd.DataFrame)
check(assert_type(df.drop(columns=iter(["col1"])), pd.DataFrame), pd.DataFrame)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

iter might be the easiest way to make an iterable

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

Can you add tests for drop(index=some_index) where some_index is an Index and also add a set for drop(columns=some_set) where some_set is a set (to correspond to the issue that's being fixed)

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

thanks @cmp0xff

@Dr-Irv Dr-Irv merged commit f7a1b83 into pandas-dev:main Feb 27, 2025
10 checks passed
@cmp0xff cmp0xff deleted the bugfix/cmp0xff/1008-dataframe-drop-columns branch February 27, 2025 17:09
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.

DataFrame.drop with columns=set(...) is unspecified
2 participants