Skip to content

Commit

Permalink
Fix a pandas-2.0 missing attribute error (#16416)
Browse files Browse the repository at this point in the history
`NumpyEADtype` is a 2.1.0+ change, this PR handles the missing attribute
error in pandas-2.0
  • Loading branch information
galipremsagar authored Jul 29, 2024
1 parent 5dd3efb commit a51964e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions python/cudf/cudf/core/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a51964e

Please sign in to comment.