From 9b31be8a8e68b9071f6441f619c1fb1893ad2cc8 Mon Sep 17 00:00:00 2001 From: galipremsagar Date: Sat, 27 Jul 2024 16:44:13 +0000 Subject: [PATCH] Fix a pandas-2.0 missing attribute error --- 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)