44import numpy as np
55import pytest
66
7- from pandas ._config import using_string_dtype
8-
97from pandas ._libs .tslibs import Timestamp
108from pandas .compat import is_platform_windows
119
2826
2927pytestmark = [
3028 pytest .mark .single_cpu ,
31- pytest .mark .xfail (using_string_dtype (), reason = "TODO(infer_string)" , strict = False ),
3229]
3330
3431
35- def test_conv_read_write ():
32+ def test_conv_read_write (using_infer_string ):
3633 with tm .ensure_clean () as path :
3734
3835 def roundtrip (key , obj , ** kwargs ):
@@ -52,13 +49,21 @@ def roundtrip(key, obj, **kwargs):
5249 columns = Index (list ("ABCD" ), dtype = object ),
5350 index = Index ([f"i-{ i } " for i in range (30 )], dtype = object ),
5451 )
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 )
5658
5759 # table
5860 df = DataFrame ({"A" : range (5 ), "B" : range (5 )})
5961 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" )
6065 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 )
6267
6368
6469def test_long_strings (setup_path ):
0 commit comments