77import numpy as np
88import pytest
99
10- from pandas ._config import using_string_dtype
11-
1210from pandas .errors import PerformanceWarning
1311import pandas .util ._test_decorators as td
1412
@@ -185,21 +183,7 @@ def test_constructor_with_convert(self):
185183 )
186184 tm .assert_series_equal (result , expected )
187185
188- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
189186 def test_construction_with_mixed (self , float_string_frame , using_infer_string ):
190- # test construction edge cases with mixed types
191-
192- # f7u12, this does not work without extensive workaround
193- data = [
194- [datetime (2001 , 1 , 5 ), np .nan , datetime (2001 , 1 , 2 )],
195- [datetime (2000 , 1 , 2 ), datetime (2000 , 1 , 3 ), datetime (2000 , 1 , 1 )],
196- ]
197- df = DataFrame (data )
198-
199- # check dtypes
200- result = df .dtypes
201- expected = Series ({"datetime64[us]" : 3 })
202-
203187 # mixed-type frames
204188 float_string_frame ["datetime" ] = datetime .now ()
205189 float_string_frame ["timedelta" ] = timedelta (days = 1 , seconds = 1 )
@@ -219,13 +203,11 @@ def test_construction_with_mixed(self, float_string_frame, using_infer_string):
219203 )
220204 tm .assert_series_equal (result , expected )
221205
222- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
223206 def test_construction_with_conversions (self ):
224207 # convert from a numpy array of non-ns timedelta64; as of 2.0 this does
225208 # *not* convert
226209 arr = np .array ([1 , 2 , 3 ], dtype = "timedelta64[s]" )
227- df = DataFrame (index = range (3 ))
228- df ["A" ] = arr
210+ df = DataFrame ({"A" : arr })
229211 expected = DataFrame (
230212 {"A" : pd .timedelta_range ("00:00:01" , periods = 3 , freq = "s" )}, index = range (3 )
231213 )
@@ -243,11 +225,11 @@ def test_construction_with_conversions(self):
243225 assert expected .dtypes ["dt1" ] == "M8[s]"
244226 assert expected .dtypes ["dt2" ] == "M8[s]"
245227
246- df = DataFrame (index = range (3 ))
247- df ["dt1" ] = np .datetime64 ("2013-01-01" )
248- df ["dt2" ] = np .array (
228+ dt1 = np .datetime64 ("2013-01-01" )
229+ dt2 = np .array (
249230 ["2013-01-01" , "2013-01-02" , "2013-01-03" ], dtype = "datetime64[D]"
250231 )
232+ df = DataFrame ({"dt1" : dt1 , "dt2" : dt2 })
251233
252234 # df['dt3'] = np.array(['2013-01-01 00:00:01','2013-01-01
253235 # 00:00:02','2013-01-01 00:00:03'],dtype='datetime64[s]')
@@ -440,14 +422,17 @@ def test_update_inplace_sets_valid_block_values(using_copy_on_write):
440422 assert df .isnull ().sum ().sum () == 0
441423
442424
443- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
444425def test_nonconsolidated_item_cache_take ():
445426 # https://github.com/pandas-dev/pandas/issues/35521
446427
447428 # create non-consolidated dataframe with object dtype columns
448- df = DataFrame ()
449- df ["col1" ] = Series (["a" ], dtype = object )
429+ df = DataFrame (
430+ {
431+ "col1" : Series (["a" ], dtype = object ),
432+ }
433+ )
450434 df ["col2" ] = Series ([0 ], dtype = object )
435+ assert not df ._mgr .is_consolidated ()
451436
452437 # access column (item cache)
453438 df ["col1" ] == "A"
0 commit comments