diff --git a/xarray/tests/test_dataarray.py b/xarray/tests/test_dataarray.py index d4f7b0f096f..e5cb1cc1349 100644 --- a/xarray/tests/test_dataarray.py +++ b/xarray/tests/test_dataarray.py @@ -11,7 +11,6 @@ import pandas as pd import pytest from packaging.version import Version -from pandas.core.computation.ops import UndefinedVariableError import xarray as xr from xarray import ( @@ -52,6 +51,13 @@ source_ndarray, ) +try: + from pandas.errors import UndefinedVariableError +except ImportError: + # TODO: remove once we stop supporting pandas<1.4.3 + from pandas.core.computation.ops import UndefinedVariableError + + pytestmark = [ pytest.mark.filterwarnings("error:Mean of empty slice"), pytest.mark.filterwarnings("error:All-NaN (slice|axis) encountered"), diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index a2c1ae1fc12..6d07787e8e3 100644 --- a/xarray/tests/test_dataset.py +++ b/xarray/tests/test_dataset.py @@ -11,7 +11,6 @@ import numpy as np import pandas as pd import pytest -from pandas.core.computation.ops import UndefinedVariableError from pandas.core.indexes.datetimes import DatetimeIndex import xarray as xr @@ -57,6 +56,13 @@ source_ndarray, ) +try: + from pandas.errors import UndefinedVariableError +except ImportError: + # TODO: remove once we stop supporting pandas<1.4.3 + from pandas.core.computation.ops import UndefinedVariableError + + try: import dask.array as da except ImportError: