Skip to content

Commit 6247a5b

Browse files
paramertize test for df.convert_dtypes()
1 parent aef1162 commit 6247a5b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

pandas/tests/frame/methods/test_convert_dtypes.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import numpy as np
22
import pytest
33

4+
import pandas.util._test_decorators as td
5+
46
import pandas as pd
57
import pandas._testing as tm
68

@@ -9,7 +11,16 @@ class TestConvertDtypes:
911
@pytest.mark.parametrize(
1012
"convert_integer, expected", [(False, np.dtype("int32")), (True, "Int32")]
1113
)
12-
def test_convert_dtypes(self, convert_integer, expected):
14+
@pytest.mark.parametrize(
15+
"string_storage",
16+
[
17+
"python",
18+
pytest.param(
19+
"pyarrow", marks=td.skip_if_no("pyarrow", min_version="1.0.0")
20+
),
21+
],
22+
)
23+
def test_convert_dtypes(self, convert_integer, expected, string_storage):
1324
# Specific types are tested in tests/series/test_dtypes.py
1425
# Just check that it works for DataFrame here
1526
df = pd.DataFrame(
@@ -18,11 +29,12 @@ def test_convert_dtypes(self, convert_integer, expected):
1829
"b": pd.Series(["x", "y", "z"], dtype=np.dtype("O")),
1930
}
2031
)
21-
result = df.convert_dtypes(True, True, convert_integer, False)
32+
with pd.option_context("string_storage", string_storage):
33+
result = df.convert_dtypes(True, True, convert_integer, False)
2234
expected = pd.DataFrame(
2335
{
2436
"a": pd.Series([1, 2, 3], dtype=expected),
25-
"b": pd.Series(["x", "y", "z"], dtype="string"),
37+
"b": pd.Series(["x", "y", "z"], dtype=f"string[{string_storage}]"),
2638
}
2739
)
2840
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)