Skip to content

Commit 3aa4b7e

Browse files
authored
BUG: Catch TypeError in _is_dtype_type when converting abstract numpy type (#62018)
Wrap np.dtype() call in try/except to handle abstract numpy types like np.floating and return condition(type(None)) on TypeError.
1 parent 62002ff commit 3aa4b7e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pandas/core/dtypes/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,10 @@ def _is_dtype_type(arr_or_dtype, condition) -> bool:
16541654
elif isinstance(arr_or_dtype, type):
16551655
if issubclass(arr_or_dtype, ExtensionDtype):
16561656
arr_or_dtype = arr_or_dtype.type
1657-
return condition(np.dtype(arr_or_dtype).type)
1657+
try:
1658+
return condition(np.dtype(arr_or_dtype).type)
1659+
except TypeError:
1660+
return condition(type(None))
16581661

16591662
# if we have an array-like
16601663
if hasattr(arr_or_dtype, "dtype"):

0 commit comments

Comments
 (0)