@@ -391,7 +391,6 @@ def _outer_indexer(
391391 _comparables : list [str ] = ["name" ]
392392 _attributes : list [str ] = ["name" ]
393393 _is_numeric_dtype : bool = False
394- _can_hold_na : bool = True
395394 _can_hold_strings : bool = True
396395
397396 # Whether this index is a NumericIndex, but not a Int64Index, Float64Index,
@@ -2206,6 +2205,20 @@ def _get_grouper_for_level(self, mapper, *, level=None):
22062205 # --------------------------------------------------------------------
22072206 # Introspection Methods
22082207
2208+ @cache_readonly
2209+ @final
2210+ def _can_hold_na (self ) -> bool :
2211+ if isinstance (self .dtype , ExtensionDtype ):
2212+ if isinstance (self .dtype , IntervalDtype ):
2213+ # FIXME(GH#45720): this is inaccurate for integer-backed
2214+ # IntervalArray, but without it other.categories.take raises
2215+ # in IntervalArray._cmp_method
2216+ return True
2217+ return self .dtype ._can_hold_na
2218+ if self .dtype .kind in ["i" , "u" , "b" ]:
2219+ return False
2220+ return True
2221+
22092222 @final
22102223 @property
22112224 def is_monotonic (self ) -> bool :
@@ -2662,10 +2675,21 @@ def inferred_type(self) -> str_t:
26622675 return lib .infer_dtype (self ._values , skipna = False )
26632676
26642677 @cache_readonly
2678+ @final
26652679 def _is_all_dates (self ) -> bool :
26662680 """
26672681 Whether or not the index values only consist of dates.
26682682 """
2683+
2684+ if needs_i8_conversion (self .dtype ):
2685+ return True
2686+ elif self .dtype != _dtype_obj :
2687+ # TODO(ExtensionIndex): 3rd party EA might override?
2688+ # Note: this includes IntervalIndex, even when the left/right
2689+ # contain datetime-like objects.
2690+ return False
2691+ elif self ._is_multi :
2692+ return False
26692693 return is_datetime_array (ensure_object (self ._values ))
26702694
26712695 @cache_readonly
@@ -6159,6 +6183,10 @@ def _is_comparable_dtype(self, dtype: DtypeObj) -> bool:
61596183 """
61606184 Can we compare values of the given dtype to our own?
61616185 """
6186+ if self .dtype .kind == "b" :
6187+ return dtype .kind == "b"
6188+ elif is_numeric_dtype (self .dtype ):
6189+ return is_numeric_dtype (dtype )
61626190 return True
61636191
61646192 @final
0 commit comments