Skip to content

Commit 8ba1ab0

Browse files
authored
Adjust tests in generic folder for arrow string option (#56139)
1 parent 22d3c9c commit 8ba1ab0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pandas/tests/generic/test_to_xarray.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def df(self):
2929
}
3030
)
3131

32-
def test_to_xarray_index_types(self, index_flat, df):
32+
def test_to_xarray_index_types(self, index_flat, df, using_infer_string):
3333
index = index_flat
3434
# MultiIndex is tested in test_to_xarray_with_multiindex
3535
if len(index) == 0:
@@ -51,7 +51,9 @@ def test_to_xarray_index_types(self, index_flat, df):
5151
# datetimes w/tz are preserved
5252
# column names are lost
5353
expected = df.copy()
54-
expected["f"] = expected["f"].astype(object)
54+
expected["f"] = expected["f"].astype(
55+
object if not using_infer_string else "string[pyarrow_numpy]"
56+
)
5557
expected.columns.name = None
5658
tm.assert_frame_equal(result.to_dataframe(), expected)
5759

@@ -63,7 +65,7 @@ def test_to_xarray_empty(self, df):
6365
assert result.dims["foo"] == 0
6466
assert isinstance(result, Dataset)
6567

66-
def test_to_xarray_with_multiindex(self, df):
68+
def test_to_xarray_with_multiindex(self, df, using_infer_string):
6769
from xarray import Dataset
6870

6971
# MultiIndex
@@ -78,7 +80,9 @@ def test_to_xarray_with_multiindex(self, df):
7880

7981
result = result.to_dataframe()
8082
expected = df.copy()
81-
expected["f"] = expected["f"].astype(object)
83+
expected["f"] = expected["f"].astype(
84+
object if not using_infer_string else "string[pyarrow_numpy]"
85+
)
8286
expected.columns.name = None
8387
tm.assert_frame_equal(result, expected)
8488

0 commit comments

Comments
 (0)