1717
1818
1919class TestDataFrameMisc :
20- @pytest .mark .parametrize ("attr" , ["index" , "columns" ])
21- def test_copy_index_name_checking (self , float_frame , attr ):
22- # don't want to be able to modify the index stored elsewhere after
23- # making a copy
24- ind = getattr (float_frame , attr )
25- ind .name = None
26- cp = float_frame .copy ()
27- getattr (cp , attr ).name = "foo"
28- assert getattr (float_frame , attr ).name is None
29-
3020 def test_getitem_pop_assign_name (self , float_frame ):
3121 s = float_frame ["A" ]
3222 assert s .name == "A"
@@ -87,8 +77,7 @@ def test_get_axis(self, float_frame):
8777 f ._get_axis_number (None )
8878
8979 def test_keys (self , float_frame ):
90- getkeys = float_frame .keys
91- assert getkeys () is float_frame .columns
80+ assert float_frame .keys () is float_frame .columns
9281
9382 def test_column_contains_raises (self , float_frame ):
9483 with pytest .raises (TypeError , match = "unhashable type: 'Index'" ):
@@ -137,15 +126,6 @@ def test_new_empty_index(self):
137126 df1 .index .name = "foo"
138127 assert df2 .index .name is None
139128
140- def test_array_interface (self , float_frame ):
141- with np .errstate (all = "ignore" ):
142- result = np .sqrt (float_frame )
143- assert isinstance (result , type (float_frame ))
144- assert result .index is float_frame .index
145- assert result .columns is float_frame .columns
146-
147- tm .assert_frame_equal (result , float_frame .apply (np .sqrt ))
148-
149129 def test_get_agg_axis (self , float_frame ):
150130 cols = float_frame ._get_agg_axis (0 )
151131 assert cols is float_frame .columns
@@ -157,7 +137,7 @@ def test_get_agg_axis(self, float_frame):
157137 with pytest .raises (ValueError , match = msg ):
158138 float_frame ._get_agg_axis (2 )
159139
160- def test_nonzero (self , float_frame , float_string_frame ):
140+ def test_empty (self , float_frame , float_string_frame ):
161141 empty_frame = DataFrame ()
162142 assert empty_frame .empty
163143
@@ -314,32 +294,6 @@ def test_len(self, float_frame):
314294 expected = float_frame .reindex (columns = ["A" , "B" ]).values
315295 tm .assert_almost_equal (arr , expected )
316296
317- def test_to_numpy (self ):
318- df = DataFrame ({"A" : [1 , 2 ], "B" : [3 , 4.5 ]})
319- expected = np .array ([[1 , 3 ], [2 , 4.5 ]])
320- result = df .to_numpy ()
321- tm .assert_numpy_array_equal (result , expected )
322-
323- def test_to_numpy_dtype (self ):
324- df = DataFrame ({"A" : [1 , 2 ], "B" : [3 , 4.5 ]})
325- expected = np .array ([[1 , 3 ], [2 , 4 ]], dtype = "int64" )
326- result = df .to_numpy (dtype = "int64" )
327- tm .assert_numpy_array_equal (result , expected )
328-
329- def test_to_numpy_copy (self ):
330- arr = np .random .randn (4 , 3 )
331- df = DataFrame (arr )
332- assert df .values .base is arr
333- assert df .to_numpy (copy = False ).base is arr
334- assert df .to_numpy (copy = True ).base is not arr
335-
336- def test_to_numpy_mixed_dtype_to_str (self ):
337- # https://github.com/pandas-dev/pandas/issues/35455
338- df = DataFrame ([[pd .Timestamp ("2020-01-01 00:00:00" ), 100.0 ]])
339- result = df .to_numpy (dtype = str )
340- expected = np .array ([["2020-01-01 00:00:00" , "100.0" ]], dtype = str )
341- tm .assert_numpy_array_equal (result , expected )
342-
343297 def test_swapaxes (self ):
344298 df = DataFrame (np .random .randn (10 , 5 ))
345299 tm .assert_frame_equal (df .T , df .swapaxes (0 , 1 ))
@@ -538,24 +492,6 @@ def test_set_flags(self, allows_duplicate_labels):
538492 result .iloc [0 , 0 ] = 10
539493 assert df .iloc [0 , 0 ] == 0
540494
541- def test_cache_on_copy (self ):
542- # GH 31784 _item_cache not cleared on copy causes incorrect reads after updates
543- df = DataFrame ({"a" : [1 ]})
544-
545- df ["x" ] = [0 ]
546- df ["a" ]
547-
548- df .copy ()
549-
550- df ["a" ].values [0 ] = - 1
551-
552- tm .assert_frame_equal (df , DataFrame ({"a" : [- 1 ], "x" : [0 ]}))
553-
554- df ["y" ] = [0 ]
555-
556- assert df ["a" ].values [0 ] == - 1
557- tm .assert_frame_equal (df , DataFrame ({"a" : [- 1 ], "x" : [0 ], "y" : [0 ]}))
558-
559495 @skip_if_no ("jinja2" )
560496 def test_constructor_expanddim_lookup (self ):
561497 # GH#33628 accessing _constructor_expanddim should not
0 commit comments