Skip to content

BUG: is_any_int_dtype not recognizing arrow integers #50683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2023
Merged
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
6 changes: 5 additions & 1 deletion pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,11 @@ def is_any_int_dtype(arr_or_dtype) -> bool:
>>> is_any_int_dtype(pd.Index([1, 2.])) # float
False
"""
return _is_dtype_type(arr_or_dtype, classes(np.integer, np.timedelta64))
return _is_dtype_type(
arr_or_dtype, classes(np.integer, np.timedelta64)
) or _is_dtype(
arr_or_dtype, lambda typ: isinstance(typ, ExtensionDtype) and typ.kind in "iu"
)


def is_integer_dtype(arr_or_dtype) -> bool:
Expand Down
11 changes: 11 additions & 0 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
)
from pandas.errors import PerformanceWarning

from pandas.core.dtypes.common import is_any_int_dtype

import pandas as pd
import pandas._testing as tm
from pandas.api.types import (
Expand Down Expand Up @@ -1459,6 +1461,15 @@ def test_is_integer_dtype(data):
assert not is_integer_dtype(data)


def test_is_any_integer_dtype(data):
# GH 50667
pa_type = data.dtype.pyarrow_dtype
if pa.types.is_integer(pa_type):
assert is_any_int_dtype(data)
else:
assert not is_any_int_dtype(data)


def test_is_signed_integer_dtype(data):
pa_type = data.dtype.pyarrow_dtype
if pa.types.is_signed_integer(pa_type):
Expand Down