7
7
import numpy as np
8
8
import pytest
9
9
10
- from pandas ._config import using_string_dtype
11
-
12
10
from pandas .errors import PerformanceWarning
13
11
import pandas .util ._test_decorators as td
14
12
@@ -185,21 +183,7 @@ def test_constructor_with_convert(self):
185
183
)
186
184
tm .assert_series_equal (result , expected )
187
185
188
- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
189
186
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
-
203
187
# mixed-type frames
204
188
float_string_frame ["datetime" ] = datetime .now ()
205
189
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):
219
203
)
220
204
tm .assert_series_equal (result , expected )
221
205
222
- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
223
206
def test_construction_with_conversions (self ):
224
207
# convert from a numpy array of non-ns timedelta64; as of 2.0 this does
225
208
# *not* convert
226
209
arr = np .array ([1 , 2 , 3 ], dtype = "timedelta64[s]" )
227
- df = DataFrame (index = range (3 ))
228
- df ["A" ] = arr
210
+ df = DataFrame ({"A" : arr })
229
211
expected = DataFrame (
230
212
{"A" : pd .timedelta_range ("00:00:01" , periods = 3 , freq = "s" )}, index = range (3 )
231
213
)
@@ -243,11 +225,11 @@ def test_construction_with_conversions(self):
243
225
assert expected .dtypes ["dt1" ] == "M8[s]"
244
226
assert expected .dtypes ["dt2" ] == "M8[s]"
245
227
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 (
249
230
["2013-01-01" , "2013-01-02" , "2013-01-03" ], dtype = "datetime64[D]"
250
231
)
232
+ df = DataFrame ({"dt1" : dt1 , "dt2" : dt2 })
251
233
252
234
# df['dt3'] = np.array(['2013-01-01 00:00:01','2013-01-01
253
235
# 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):
440
422
assert df .isnull ().sum ().sum () == 0
441
423
442
424
443
- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
444
425
def test_nonconsolidated_item_cache_take ():
445
426
# https://github.com/pandas-dev/pandas/issues/35521
446
427
447
428
# 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
+ )
450
434
df ["col2" ] = Series ([0 ], dtype = object )
435
+ assert not df ._mgr .is_consolidated ()
451
436
452
437
# access column (item cache)
453
438
df ["col1" ] == "A"
0 commit comments