Skip to content

Commit ad6ed76

Browse files
committed
TST(string dtype): Resolve HDF5 xfails in test_round_trip.py
1 parent d81882b commit ad6ed76

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

pandas/tests/io/pytables/test_round_trip.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import numpy as np
55
import pytest
66

7-
from pandas._config import using_string_dtype
8-
97
from pandas._libs.tslibs import Timestamp
108
from pandas.compat import is_platform_windows
119

@@ -28,11 +26,10 @@
2826

2927
pytestmark = [
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

6469
def test_long_strings(setup_path):

0 commit comments

Comments
 (0)