7
7
import numpy as np
8
8
import pytest
9
9
10
- from pandas ._config import using_string_dtype
11
-
12
10
import pandas as pd
13
11
from pandas import (
14
12
Categorical ,
@@ -162,21 +160,7 @@ def test_constructor_with_convert(self):
162
160
)
163
161
tm .assert_series_equal (result , expected )
164
162
165
- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
166
163
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
-
180
164
# mixed-type frames
181
165
float_string_frame ["datetime" ] = datetime .now ()
182
166
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):
196
180
)
197
181
tm .assert_series_equal (result , expected )
198
182
199
- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
200
183
def test_construction_with_conversions (self ):
201
184
# convert from a numpy array of non-ns timedelta64; as of 2.0 this does
202
185
# *not* convert
203
186
arr = np .array ([1 , 2 , 3 ], dtype = "timedelta64[s]" )
204
- df = DataFrame (index = range (3 ))
205
- df ["A" ] = arr
187
+ df = DataFrame ({"A" : arr })
206
188
expected = DataFrame (
207
189
{"A" : pd .timedelta_range ("00:00:01" , periods = 3 , freq = "s" )}, index = range (3 )
208
190
)
@@ -220,11 +202,11 @@ def test_construction_with_conversions(self):
220
202
assert expected .dtypes ["dt1" ] == "M8[s]"
221
203
assert expected .dtypes ["dt2" ] == "M8[s]"
222
204
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 (
226
207
["2013-01-01" , "2013-01-02" , "2013-01-03" ], dtype = "datetime64[D]"
227
208
)
209
+ df = DataFrame ({"dt1" : dt1 , "dt2" : dt2 })
228
210
229
211
# df['dt3'] = np.array(['2013-01-01 00:00:01','2013-01-01
230
212
# 00:00:02','2013-01-01 00:00:03'],dtype='datetime64[s]')
@@ -401,14 +383,17 @@ def test_update_inplace_sets_valid_block_values():
401
383
assert isinstance (df ._mgr .blocks [0 ].values , Categorical )
402
384
403
385
404
- @pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" )
405
386
def test_nonconsolidated_item_cache_take ():
406
387
# https://github.com/pandas-dev/pandas/issues/35521
407
388
408
389
# 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
+ )
411
395
df ["col2" ] = Series ([0 ], dtype = object )
396
+ assert not df ._mgr .is_consolidated ()
412
397
413
398
# access column (item cache)
414
399
df ["col1" ] == "A"
0 commit comments