77import numpy as np
88import pytest
99
10- from pandas ._config import using_string_dtype
11-
1210import pandas as pd
1311from pandas import (
1412 Categorical ,
@@ -162,21 +160,7 @@ def test_constructor_with_convert(self):
162160 )
163161 tm .assert_series_equal (result , expected )
164162
165- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
166163 def test_construction_with_mixed (self , float_string_frame , using_infer_string ):
167- # test construction edge cases with mixed types
168-
169- # f7u12, this does not work without extensive workaround
170- data = [
171- [datetime (2001 , 1 , 5 ), np .nan , datetime (2001 , 1 , 2 )],
172- [datetime (2000 , 1 , 2 ), datetime (2000 , 1 , 3 ), datetime (2000 , 1 , 1 )],
173- ]
174- df = DataFrame (data )
175-
176- # check dtypes
177- result = df .dtypes
178- expected = Series ({"datetime64[us]" : 3 })
179-
180164 # mixed-type frames
181165 float_string_frame ["datetime" ] = datetime .now ()
182166 float_string_frame ["timedelta" ] = timedelta (days = 1 , seconds = 1 )
@@ -196,13 +180,11 @@ def test_construction_with_mixed(self, float_string_frame, using_infer_string):
196180 )
197181 tm .assert_series_equal (result , expected )
198182
199- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
200183 def test_construction_with_conversions (self ):
201184 # convert from a numpy array of non-ns timedelta64; as of 2.0 this does
202185 # *not* convert
203186 arr = np .array ([1 , 2 , 3 ], dtype = "timedelta64[s]" )
204- df = DataFrame (index = range (3 ))
205- df ["A" ] = arr
187+ df = DataFrame ({"A" : arr })
206188 expected = DataFrame (
207189 {"A" : pd .timedelta_range ("00:00:01" , periods = 3 , freq = "s" )}, index = range (3 )
208190 )
@@ -220,11 +202,11 @@ def test_construction_with_conversions(self):
220202 assert expected .dtypes ["dt1" ] == "M8[s]"
221203 assert expected .dtypes ["dt2" ] == "M8[s]"
222204
223- df = DataFrame (index = range (3 ))
224- df ["dt1" ] = np .datetime64 ("2013-01-01" )
225- df ["dt2" ] = np .array (
205+ dt1 = np .datetime64 ("2013-01-01" )
206+ dt2 = np .array (
226207 ["2013-01-01" , "2013-01-02" , "2013-01-03" ], dtype = "datetime64[D]"
227208 )
209+ df = DataFrame ({"dt1" : dt1 , "dt2" : dt2 })
228210
229211 # df['dt3'] = np.array(['2013-01-01 00:00:01','2013-01-01
230212 # 00:00:02','2013-01-01 00:00:03'],dtype='datetime64[s]')
@@ -401,14 +383,17 @@ def test_update_inplace_sets_valid_block_values():
401383 assert isinstance (df ._mgr .blocks [0 ].values , Categorical )
402384
403385
404- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
405386def test_nonconsolidated_item_cache_take ():
406387 # https://github.com/pandas-dev/pandas/issues/35521
407388
408389 # create non-consolidated dataframe with object dtype columns
409- df = DataFrame ()
410- df ["col1" ] = Series (["a" ], dtype = object )
390+ df = DataFrame (
391+ {
392+ "col1" : Series (["a" ], dtype = object ),
393+ }
394+ )
411395 df ["col2" ] = Series ([0 ], dtype = object )
396+ assert not df ._mgr .is_consolidated ()
412397
413398 # access column (item cache)
414399 df ["col1" ] == "A"
0 commit comments