-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
DEPR: DataFrame.swapaxes #51960
Conversation
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) |
There was a problem hiding this comment.
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)
@@ -251,7 +251,6 @@ | |||
operator.methodcaller("isin", pd.DataFrame({"A": [1]})), | |||
), | |||
), | |||
(pd.DataFrame, frame_data, operator.methodcaller("swapaxes", 0, 1)), |
There was a problem hiding this comment.
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.
with tm.assert_produces_warning( | ||
FutureWarning, match=".swapaxes' is deprecated", check_stacklevel=False | ||
): | ||
assert len(np.array_split(o, 5)) == 5 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Co-authored-by: Matthew Roeschke <[email protected]>
Thanks @luke396 |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.