Skip to content

Commit 6c85d11

Browse files
[backport 2.3.x] TST: update xfail xarray version check in to_xarray test (#61648) (#61652)
TST: update xfail xarray version check in to_xarray test (#61648)
1 parent 3081fd2 commit 6c85d11

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

pandas/tests/generic/test_to_xarray.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
DataFrame,
77
MultiIndex,
88
Series,
9+
StringDtype,
910
date_range,
1011
)
1112
import pandas._testing as tm
13+
from pandas.util.version import Version
1214

13-
pytest.importorskip("xarray")
15+
xarray = pytest.importorskip("xarray")
1416

1517

1618
class TestDataFrameToXArray:
@@ -88,8 +90,20 @@ def test_to_xarray_with_multiindex(self, df, using_infer_string):
8890

8991

9092
class TestSeriesToXArray:
91-
def test_to_xarray_index_types(self, index_flat):
93+
def test_to_xarray_index_types(self, index_flat, request):
9294
index = index_flat
95+
if (
96+
isinstance(index.dtype, StringDtype)
97+
and index.dtype.storage == "pyarrow"
98+
and Version(xarray.__version__) > Version("2024.9.0")
99+
and Version(xarray.__version__) < Version("2025.6.0")
100+
):
101+
request.applymarker(
102+
pytest.mark.xfail(
103+
reason="xarray calling reshape of ArrowExtensionArray",
104+
raises=NotImplementedError,
105+
)
106+
)
93107
# MultiIndex is tested in test_to_xarray_with_multiindex
94108

95109
from xarray import DataArray

0 commit comments

Comments
 (0)