@@ -86,7 +86,6 @@ def test_copy_shallow(using_copy_on_write):
86
86
lambda df , copy : df .rename_axis (columns = "test" , copy = copy ),
87
87
lambda df , copy : df .astype ({"b" : "int64" }, copy = copy ),
88
88
# lambda df, copy: df.swaplevel(0, 0, copy=copy),
89
- lambda df , copy : df .swapaxes (0 , 0 , copy = copy ),
90
89
lambda df , copy : df .truncate (0 , 5 , copy = copy ),
91
90
lambda df , copy : df .infer_objects (copy = copy ),
92
91
lambda df , copy : df .to_timestamp (copy = copy ),
@@ -105,7 +104,6 @@ def test_copy_shallow(using_copy_on_write):
105
104
"rename_axis1" ,
106
105
"astype" ,
107
106
# "swaplevel", # only series
108
- "swapaxes" ,
109
107
"truncate" ,
110
108
"infer_objects" ,
111
109
"to_timestamp" ,
@@ -127,13 +125,7 @@ def test_methods_copy_keyword(request, method, copy, using_copy_on_write):
127
125
index = date_range ("2012-01-01" , freq = "D" , periods = 3 , tz = "Europe/Brussels" )
128
126
129
127
df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ], "c" : [0.1 , 0.2 , 0.3 ]}, index = index )
130
-
131
- if "swapaxes" in request .node .callspec .id :
132
- msg = "'DataFrame.swapaxes' is deprecated"
133
- with tm .assert_produces_warning (FutureWarning , match = msg ):
134
- df2 = method (df , copy = copy )
135
- else :
136
- df2 = method (df , copy = copy )
128
+ df2 = method (df , copy = copy )
137
129
138
130
share_memory = using_copy_on_write or copy is False
139
131
@@ -161,7 +153,6 @@ def test_methods_copy_keyword(request, method, copy, using_copy_on_write):
161
153
lambda ser , copy : ser .rename_axis (index = "test" , copy = copy ),
162
154
lambda ser , copy : ser .astype ("int64" , copy = copy ),
163
155
lambda ser , copy : ser .swaplevel (0 , 1 , copy = copy ),
164
- lambda ser , copy : ser .swapaxes (0 , 0 , copy = copy ),
165
156
lambda ser , copy : ser .truncate (0 , 5 , copy = copy ),
166
157
lambda ser , copy : ser .infer_objects (copy = copy ),
167
158
lambda ser , copy : ser .to_timestamp (copy = copy ),
@@ -180,7 +171,6 @@ def test_methods_copy_keyword(request, method, copy, using_copy_on_write):
180
171
"rename_axis0" ,
181
172
"astype" ,
182
173
"swaplevel" ,
183
- "swapaxes" ,
184
174
"truncate" ,
185
175
"infer_objects" ,
186
176
"to_timestamp" ,
@@ -204,13 +194,7 @@ def test_methods_series_copy_keyword(request, method, copy, using_copy_on_write)
204
194
index = MultiIndex .from_arrays ([[1 , 2 , 3 ], [4 , 5 , 6 ]])
205
195
206
196
ser = Series ([1 , 2 , 3 ], index = index )
207
-
208
- if "swapaxes" in request .node .callspec .id :
209
- msg = "'Series.swapaxes' is deprecated"
210
- with tm .assert_produces_warning (FutureWarning , match = msg ):
211
- ser2 = method (ser , copy = copy )
212
- else :
213
- ser2 = method (ser , copy = copy )
197
+ ser2 = method (ser , copy = copy )
214
198
215
199
share_memory = using_copy_on_write or copy is False
216
200
@@ -688,55 +672,6 @@ def test_to_frame(using_copy_on_write):
688
672
tm .assert_frame_equal (df , expected )
689
673
690
674
691
- @pytest .mark .parametrize ("ax" , ["index" , "columns" ])
692
- def test_swapaxes_noop (using_copy_on_write , ax ):
693
- df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
694
- df_orig = df .copy ()
695
- msg = "'DataFrame.swapaxes' is deprecated"
696
- with tm .assert_produces_warning (FutureWarning , match = msg ):
697
- df2 = df .swapaxes (ax , ax )
698
-
699
- if using_copy_on_write :
700
- assert np .shares_memory (get_array (df2 , "a" ), get_array (df , "a" ))
701
- else :
702
- assert not np .shares_memory (get_array (df2 , "a" ), get_array (df , "a" ))
703
-
704
- # mutating df2 triggers a copy-on-write for that column/block
705
- df2 .iloc [0 , 0 ] = 0
706
- if using_copy_on_write :
707
- assert not np .shares_memory (get_array (df2 , "a" ), get_array (df , "a" ))
708
- tm .assert_frame_equal (df , df_orig )
709
-
710
-
711
- def test_swapaxes_single_block (using_copy_on_write ):
712
- df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]}, index = ["x" , "y" , "z" ])
713
- df_orig = df .copy ()
714
- msg = "'DataFrame.swapaxes' is deprecated"
715
- with tm .assert_produces_warning (FutureWarning , match = msg ):
716
- df2 = df .swapaxes ("index" , "columns" )
717
-
718
- if using_copy_on_write :
719
- assert np .shares_memory (get_array (df2 , "x" ), get_array (df , "a" ))
720
- else :
721
- assert not np .shares_memory (get_array (df2 , "x" ), get_array (df , "a" ))
722
-
723
- # mutating df2 triggers a copy-on-write for that column/block
724
- df2 .iloc [0 , 0 ] = 0
725
- if using_copy_on_write :
726
- assert not np .shares_memory (get_array (df2 , "x" ), get_array (df , "a" ))
727
- tm .assert_frame_equal (df , df_orig )
728
-
729
-
730
- def test_swapaxes_read_only_array ():
731
- df = DataFrame ({"a" : [1 , 2 ], "b" : 3 })
732
- msg = "'DataFrame.swapaxes' is deprecated"
733
- with tm .assert_produces_warning (FutureWarning , match = msg ):
734
- df = df .swapaxes (axis1 = "index" , axis2 = "columns" )
735
- df .iloc [0 , 0 ] = 100
736
- expected = DataFrame ({0 : [100 , 3 ], 1 : [2 , 3 ]}, index = ["a" , "b" ])
737
- tm .assert_frame_equal (df , expected )
738
-
739
-
740
675
@pytest .mark .parametrize (
741
676
"method, idx" ,
742
677
[
0 commit comments