From d051d891365405fbd8a61f055169d662b5aa4ed8 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Fri, 13 Jun 2025 15:31:19 +0200 Subject: [PATCH] TST: update xfail xarray version check in to_xarray test (#61648) --- pandas/tests/generic/test_to_xarray.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pandas/tests/generic/test_to_xarray.py b/pandas/tests/generic/test_to_xarray.py index 9fe9bca8abdc9..9b589c9348c35 100644 --- a/pandas/tests/generic/test_to_xarray.py +++ b/pandas/tests/generic/test_to_xarray.py @@ -6,11 +6,13 @@ DataFrame, MultiIndex, Series, + StringDtype, date_range, ) import pandas._testing as tm +from pandas.util.version import Version -pytest.importorskip("xarray") +xarray = pytest.importorskip("xarray") class TestDataFrameToXArray: @@ -88,8 +90,20 @@ def test_to_xarray_with_multiindex(self, df, using_infer_string): class TestSeriesToXArray: - def test_to_xarray_index_types(self, index_flat): + def test_to_xarray_index_types(self, index_flat, request): index = index_flat + if ( + isinstance(index.dtype, StringDtype) + and index.dtype.storage == "pyarrow" + and Version(xarray.__version__) > Version("2024.9.0") + and Version(xarray.__version__) < Version("2025.6.0") + ): + request.applymarker( + pytest.mark.xfail( + reason="xarray calling reshape of ArrowExtensionArray", + raises=NotImplementedError, + ) + ) # MultiIndex is tested in test_to_xarray_with_multiindex from xarray import DataArray