Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/dtypes/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
Loading