From 17b6942c76fba8128d47cfbf0e58f07cfb7af5fb Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 22 Aug 2023 09:03:55 -0700 Subject: [PATCH] BUG: inaccurate Index._can_hold_na --- pandas/core/arrays/interval.py | 2 +- pandas/core/indexes/base.py | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index 3263dd73fe4dc..9c2e85c4df564 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -764,7 +764,7 @@ def _cmp_method(self, other, op): if self.closed != other.categories.closed: return invalid_comparison(self, other, op) - other = other.categories.take( + other = other.categories._values.take( other.codes, allow_fill=True, fill_value=other.categories._na_value ) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 796aadf9e4061..2305c1cbb698e 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -2172,11 +2172,6 @@ def _drop_level_numbers(self, levnums: list[int]): @final def _can_hold_na(self) -> bool: if isinstance(self.dtype, ExtensionDtype): - if isinstance(self.dtype, IntervalDtype): - # FIXME(GH#45720): this is inaccurate for integer-backed - # IntervalArray, but without it other.categories.take raises - # in IntervalArray._cmp_method - return True return self.dtype._can_hold_na if self.dtype.kind in "iub": return False