From a51964ed8b00c3c88d463e329af7ec8378642343 Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Mon, 29 Jul 2024 08:42:27 -0500 Subject: [PATCH] Fix a `pandas-2.0` missing attribute error (#16416) `NumpyEADtype` is a 2.1.0+ change, this PR handles the missing attribute error in pandas-2.0 --- python/cudf/cudf/core/dtypes.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/cudf/cudf/core/dtypes.py b/python/cudf/cudf/core/dtypes.py index de715191c08..27afec18b4e 100644 --- a/python/cudf/cudf/core/dtypes.py +++ b/python/cudf/cudf/core/dtypes.py @@ -17,10 +17,15 @@ from pandas.core.arrays.arrow.extension_types import ArrowIntervalType import cudf -from cudf.core._compat import PANDAS_LT_300 +from cudf.core._compat import PANDAS_GE_210, PANDAS_LT_300 from cudf.core.abc import Serializable from cudf.utils.docutils import doc_apply +if PANDAS_GE_210: + PANDAS_NUMPY_DTYPE = pd.core.dtypes.dtypes.NumpyEADtype +else: + PANDAS_NUMPY_DTYPE = pd.core.dtypes.dtypes.PandasDtype + if TYPE_CHECKING: from cudf._typing import Dtype from cudf.core.buffer import Buffer @@ -72,7 +77,7 @@ def dtype(arbitrary): return np.dtype("object") else: return dtype(pd_dtype.numpy_dtype) - elif isinstance(pd_dtype, pd.core.dtypes.dtypes.NumpyEADtype): + elif isinstance(pd_dtype, PANDAS_NUMPY_DTYPE): return dtype(pd_dtype.numpy_dtype) elif isinstance(pd_dtype, pd.CategoricalDtype): return cudf.CategoricalDtype.from_pandas(pd_dtype)