-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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
Changes from 9 commits
1c4c627
38ca9cf
7dd96b4
158961b
9890bf9
5b60460
3595fb4
532ee3a
91c2346
3c027ec
058043d
1522aa4
a052f5e
126817c
5f66aee
6647c6e
d23f0df
2b31454
09cf70a
f1f661b
02811fb
8b7cd97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,22 +8,30 @@ | |
class TestSwapAxes: | ||
def test_swapaxes(self): | ||
df = DataFrame(np.random.randn(10, 5)) | ||
tm.assert_frame_equal(df.T, df.swapaxes(0, 1)) | ||
tm.assert_frame_equal(df.T, df.swapaxes(1, 0)) | ||
msg = "'DataFrame.swapaxes' is deprecated" | ||
with tm.assert_produces_warning(FutureWarning, match=msg): | ||
tm.assert_frame_equal(df.T, df.swapaxes(0, 1)) | ||
tm.assert_frame_equal(df.T, df.swapaxes(1, 0)) | ||
|
||
def test_swapaxes_noop(self): | ||
df = DataFrame(np.random.randn(10, 5)) | ||
tm.assert_frame_equal(df, df.swapaxes(0, 0)) | ||
msg = "'DataFrame.swapaxes' is deprecated" | ||
with tm.assert_produces_warning(FutureWarning, match=msg): | ||
tm.assert_frame_equal(df, df.swapaxes(0, 0)) | ||
|
||
def test_swapaxes_invalid_axis(self): | ||
df = DataFrame(np.random.randn(10, 5)) | ||
msg = "No axis named 2 for object type DataFrame" | ||
with pytest.raises(ValueError, match=msg): | ||
df.swapaxes(2, 5) | ||
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) | ||
Comment on lines
+24
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if nested blocks of code are better expressed. ( |
||
|
||
def test_round_empty_not_input(self): | ||
# GH#51032 | ||
df = DataFrame({"a": [1, 2]}) | ||
result = df.swapaxes("index", "index") | ||
msg = "'DataFrame.swapaxes' is deprecated" | ||
with tm.assert_produces_warning(FutureWarning, match=msg): | ||
result = df.swapaxes("index", "index") | ||
tm.assert_frame_equal(df, result) | ||
assert df is not result |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 |
||
(pd.DataFrame, frame_mi_data, operator.methodcaller("droplevel", "A")), | ||
(pd.DataFrame, frame_data, operator.methodcaller("pop", "A")), | ||
pytest.param( | ||
|
Uh oh!
There was an error while loading. Please reload this page.