Skip to content

DEPR: DataFrame.swapaxes #51960

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

Merged
merged 22 commits into from
Mar 25, 2023
Merged

Conversation

luke396
Copy link
Contributor

@luke396 luke396 commented Mar 14, 2023

Comment on lines +24 to +28
msg = "'DataFrame.swapaxes' is deprecated"
with tm.assert_produces_warning(FutureWarning, match=msg):
msg = "No axis named 2 for object type DataFrame"
with pytest.raises(ValueError, match=msg):
df.swapaxes(2, 5)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if nested blocks of code are better expressed. (pytest may break pre-commit)

@mroeschke mroeschke added the Deprecate Functionality to remove in pandas label Mar 14, 2023
@@ -251,7 +251,6 @@
operator.methodcaller("isin", pd.DataFrame({"A": [1]})),
),
),
(pd.DataFrame, frame_data, operator.methodcaller("swapaxes", 0, 1)),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that this file is testing all existing finalize methods, so I removed swapaxes due to its depreciation.

@luke396 luke396 requested a review from phofl March 15, 2023 07:51
with tm.assert_produces_warning(
FutureWarning, match=".swapaxes' is deprecated", check_stacklevel=False
):
assert len(np.array_split(o, 5)) == 5
Copy link
Member

Choose a reason for hiding this comment

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

Why is swapaxes being called here?

Copy link
Contributor Author

@luke396 luke396 Mar 21, 2023

Choose a reason for hiding this comment

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

/home/luke/mambaforge/envs/pandas-dev/lib/python3.8/site-packages/numpy/core/fromnumeric.py:57: FutureWarning: 'DataFrame.swapaxes' is deprecated and will be removed in a future version. Please use 'DataFrame.transpose' instead.
    return bound(*args, **kwds)

It will raise an warning (maybenp.array_split to np.swapaxes to df.swapaxes, I'm not sure), and let CI "Numpy Dev" failed.

Copy link
Member

Choose a reason for hiding this comment

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

Will np.array_split cease to work once swapaxes is removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes. If remove swapaxes, this test will work find, without the depreciation waring.

@mroeschke mroeschke added this to the 2.1 milestone Mar 25, 2023
@mroeschke mroeschke merged commit eae6000 into pandas-dev:main Mar 25, 2023
@mroeschke
Copy link
Member

Thanks @luke396

@luke396 luke396 deleted the depr-dataframe-swapaxes branch March 26, 2023 00:07
@ddelange ddelange mentioned this pull request Mar 7, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEPR: DataFrame.swapaxes
3 participants