diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index 68d99937f728c..49a602a352372 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -840,6 +840,10 @@ def is_signed_integer_dtype(arr_or_dtype) -> bool: >>> is_signed_integer_dtype(np.array([1, 2], dtype=np.uint32)) # unsigned False """ + if isinstance(arr_or_dtype, type) and issubclass( + arr_or_dtype, (np.floating, np.inexact, np.generic) + ): + return False return _is_dtype_type( arr_or_dtype, _classes_and_not_datetimelike(np.signedinteger) ) or _is_dtype( diff --git a/pandas/tests/dtypes/test_dtypes.py b/pandas/tests/dtypes/test_dtypes.py index c9d3f83ce9237..afc701b1c4940 100644 --- a/pandas/tests/dtypes/test_dtypes.py +++ b/pandas/tests/dtypes/test_dtypes.py @@ -17,6 +17,7 @@ is_dtype_equal, is_interval_dtype, is_period_dtype, + is_signed_integer_dtype, is_string_dtype, ) from pandas.core.dtypes.dtypes import ( @@ -1150,6 +1151,13 @@ def test_is_bool_dtype(dtype, expected): assert result is expected +def test_is_signed_integer_dtype_with_abstract_types(): + # GH 62018 + assert is_signed_integer_dtype(np.floating) is False + assert is_signed_integer_dtype(np.inexact) is False + assert is_signed_integer_dtype(np.generic) is False + + def test_is_bool_dtype_sparse(): result = is_bool_dtype(Series(SparseArray([True, False]))) assert result is True