4
4
import numpy as np
5
5
import pytest
6
6
7
- from pandas ._config import using_string_dtype
8
-
9
7
from pandas ._libs .tslibs import Timestamp
10
8
from pandas .compat import is_platform_windows
11
9
28
26
29
27
pytestmark = [
30
28
pytest .mark .single_cpu ,
31
- pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" , strict = False ),
32
29
]
33
30
34
31
35
- def test_conv_read_write ():
32
+ def test_conv_read_write (using_infer_string ):
36
33
with tm .ensure_clean () as path :
37
34
38
35
def roundtrip (key , obj , ** kwargs ):
@@ -52,13 +49,21 @@ def roundtrip(key, obj, **kwargs):
52
49
columns = Index (list ("ABCD" ), dtype = object ),
53
50
index = Index ([f"i-{ i } " for i in range (30 )], dtype = object ),
54
51
)
55
- tm .assert_frame_equal (o , roundtrip ("frame" , o ))
52
+ expected = o
53
+ if using_infer_string :
54
+ expected .index = expected .index .astype ("str" )
55
+ expected .columns = expected .columns .astype ("str" )
56
+ result = roundtrip ("frame" , o )
57
+ tm .assert_frame_equal (result , expected )
56
58
57
59
# table
58
60
df = DataFrame ({"A" : range (5 ), "B" : range (5 )})
59
61
df .to_hdf (path , key = "table" , append = True )
62
+ expected = df [df .index > 2 ]
63
+ if using_infer_string :
64
+ expected .columns = expected .columns .astype ("str" )
60
65
result = read_hdf (path , "table" , where = ["index>2" ])
61
- tm .assert_frame_equal (df [ df . index > 2 ], result )
66
+ tm .assert_frame_equal (result , expected )
62
67
63
68
64
69
def test_long_strings (setup_path ):
0 commit comments