@@ -86,7 +86,6 @@ def test_copy_shallow(using_copy_on_write):
8686 lambda df , copy : df .rename_axis (columns = "test" , copy = copy ),
8787 lambda df , copy : df .astype ({"b" : "int64" }, copy = copy ),
8888 # lambda df, copy: df.swaplevel(0, 0, copy=copy),
89- lambda df , copy : df .swapaxes (0 , 0 , copy = copy ),
9089 lambda df , copy : df .truncate (0 , 5 , copy = copy ),
9190 lambda df , copy : df .infer_objects (copy = copy ),
9291 lambda df , copy : df .to_timestamp (copy = copy ),
@@ -105,7 +104,6 @@ def test_copy_shallow(using_copy_on_write):
105104 "rename_axis1" ,
106105 "astype" ,
107106 # "swaplevel", # only series
108- "swapaxes" ,
109107 "truncate" ,
110108 "infer_objects" ,
111109 "to_timestamp" ,
@@ -127,13 +125,7 @@ def test_methods_copy_keyword(request, method, copy, using_copy_on_write):
127125 index = date_range ("2012-01-01" , freq = "D" , periods = 3 , tz = "Europe/Brussels" )
128126
129127 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 )
137129
138130 share_memory = using_copy_on_write or copy is False
139131
@@ -161,7 +153,6 @@ def test_methods_copy_keyword(request, method, copy, using_copy_on_write):
161153 lambda ser , copy : ser .rename_axis (index = "test" , copy = copy ),
162154 lambda ser , copy : ser .astype ("int64" , copy = copy ),
163155 lambda ser , copy : ser .swaplevel (0 , 1 , copy = copy ),
164- lambda ser , copy : ser .swapaxes (0 , 0 , copy = copy ),
165156 lambda ser , copy : ser .truncate (0 , 5 , copy = copy ),
166157 lambda ser , copy : ser .infer_objects (copy = copy ),
167158 lambda ser , copy : ser .to_timestamp (copy = copy ),
@@ -180,7 +171,6 @@ def test_methods_copy_keyword(request, method, copy, using_copy_on_write):
180171 "rename_axis0" ,
181172 "astype" ,
182173 "swaplevel" ,
183- "swapaxes" ,
184174 "truncate" ,
185175 "infer_objects" ,
186176 "to_timestamp" ,
@@ -204,13 +194,7 @@ def test_methods_series_copy_keyword(request, method, copy, using_copy_on_write)
204194 index = MultiIndex .from_arrays ([[1 , 2 , 3 ], [4 , 5 , 6 ]])
205195
206196 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 )
214198
215199 share_memory = using_copy_on_write or copy is False
216200
@@ -688,55 +672,6 @@ def test_to_frame(using_copy_on_write):
688672 tm .assert_frame_equal (df , expected )
689673
690674
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-
740675@pytest .mark .parametrize (
741676 "method, idx" ,
742677 [
0 commit comments