Skip to content

Commit 514a7c0

Browse files
author
Jiang Yue
committed
add test for integer-na
1 parent f1b9408 commit 514a7c0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pandas/core/indexes/base.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3197,8 +3197,10 @@ def is_int(v):
31973197
self.get_loc(stop)
31983198
is_positional = False
31993199
except KeyError:
3200-
if (self.inferred_type == "mixed-integer-float" or
3201-
self.inferred_type == "integer-na"):
3200+
if (
3201+
self.inferred_type == "mixed-integer-float"
3202+
or self.inferred_type == "integer-na"
3203+
):
32023204
raise
32033205

32043206
if is_null_slicer:

pandas/tests/dtypes/test_inference.py

+10
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,16 @@ def test_integers(self):
577577
result = lib.infer_dtype(arr, skipna=True)
578578
assert result == "integer"
579579

580+
# GH 27392
581+
def test_integer_na(self):
582+
arr = np.array([1, 2, np.nan, np.nan, 3], dtype="O")
583+
result = lib.infer_dtype(arr, skipna=False)
584+
assert result == "integer-na"
585+
586+
arr = np.array([1, 2, 3, np.int64(4), np.int32(5), np.nan], dtype="O")
587+
result = lib.infer_dtype(arr, skipna=False)
588+
assert result == "integer-na"
589+
580590
def test_deprecation(self):
581591
# GH 24050
582592
arr = np.array([1, 2, 3], dtype=object)

0 commit comments

Comments
 (0)