Skip to content

Commit 0851ea8

Browse files
committed
Add test for string dtype
1 parent 4c0e07d commit 0851ea8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pandas/tests/io/pytables/test_put.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,15 @@ def test_put_compression_blosc(setup_path):
200200
tm.assert_frame_equal(result, expected)
201201

202202

203-
def test_put_mixed_type(setup_path, performance_warning):
203+
def test_put_mixed_type(setup_path, performance_warning, using_infer_string):
204204
df = DataFrame(
205205
np.random.default_rng(2).standard_normal((10, 4)),
206206
columns=Index(list("ABCD")),
207207
index=date_range("2000-01-01", periods=10, freq="B"),
208208
)
209209
df["obj1"] = "foo"
210-
df["obj2"] = "bar"
210+
df["obj2"] = [pd.NA] + 9 * ["bar"]
211+
df["obj2"] = df["obj2"].astype("string")
211212
df["bool1"] = df["A"] > 0
212213
df["bool2"] = df["B"] > 0
213214
df["bool3"] = True
@@ -226,7 +227,11 @@ def test_put_mixed_type(setup_path, performance_warning):
226227
with tm.assert_produces_warning(performance_warning):
227228
store.put("df", df)
228229

229-
expected = df
230+
expected = df.copy()
231+
if using_infer_string:
232+
expected["obj2"] = expected["obj2"].astype("str")
233+
else:
234+
expected["obj2"] = expected["obj2"].astype("object")
230235
result = store.get("df")
231236
tm.assert_frame_equal(result, expected)
232237

0 commit comments

Comments
 (0)