Skip to content

Commit dc295d6

Browse files
authored
BUG: is_any_int_dtype not recognizing arrow integers (#50683)
1 parent eddb6f4 commit dc295d6

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

pandas/core/dtypes/common.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,11 @@ def is_any_int_dtype(arr_or_dtype) -> bool:
638638
>>> is_any_int_dtype(pd.Index([1, 2.])) # float
639639
False
640640
"""
641-
return _is_dtype_type(arr_or_dtype, classes(np.integer, np.timedelta64))
641+
return _is_dtype_type(
642+
arr_or_dtype, classes(np.integer, np.timedelta64)
643+
) or _is_dtype(
644+
arr_or_dtype, lambda typ: isinstance(typ, ExtensionDtype) and typ.kind in "iu"
645+
)
642646

643647

644648
def is_integer_dtype(arr_or_dtype) -> bool:

pandas/tests/extension/test_arrow.py

+11
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
)
3636
from pandas.errors import PerformanceWarning
3737

38+
from pandas.core.dtypes.common import is_any_int_dtype
39+
3840
import pandas as pd
3941
import pandas._testing as tm
4042
from pandas.api.types import (
@@ -1459,6 +1461,15 @@ def test_is_integer_dtype(data):
14591461
assert not is_integer_dtype(data)
14601462

14611463

1464+
def test_is_any_integer_dtype(data):
1465+
# GH 50667
1466+
pa_type = data.dtype.pyarrow_dtype
1467+
if pa.types.is_integer(pa_type):
1468+
assert is_any_int_dtype(data)
1469+
else:
1470+
assert not is_any_int_dtype(data)
1471+
1472+
14621473
def test_is_signed_integer_dtype(data):
14631474
pa_type = data.dtype.pyarrow_dtype
14641475
if pa.types.is_signed_integer(pa_type):

0 commit comments

Comments
 (0)