@@ -481,6 +481,10 @@ def __new__(
481481 if data .dtype .kind in ["i" , "u" , "f" ]:
482482 # maybe coerce to a sub-class
483483 arr = data
484+ elif data .dtype .kind == "b" :
485+ # No special subclass, and Index._ensure_array won't do this
486+ # for us.
487+ arr = np .asarray (data )
484488 else :
485489 arr = com .asarray_tuplesafe (data , dtype = np .dtype ("object" ))
486490
@@ -672,7 +676,7 @@ def _with_infer(cls, *args, **kwargs):
672676 # "Union[ExtensionArray, ndarray[Any, Any]]"; expected
673677 # "ndarray[Any, Any]"
674678 values = lib .maybe_convert_objects (result ._values ) # type: ignore[arg-type]
675- if values .dtype .kind in ["i" , "u" , "f" ]:
679+ if values .dtype .kind in ["i" , "u" , "f" , "b" ]:
676680 return Index (values , name = result .name )
677681
678682 return result
@@ -837,6 +841,8 @@ def _engine(self) -> libindex.IndexEngine:
837841 # to avoid a reference cycle, bind `target_values` to a local variable, so
838842 # `self` is not passed into the lambda.
839843 target_values = self ._get_engine_target ()
844+ if target_values .dtype == bool :
845+ return libindex .BoolEngine (target_values )
840846 return self ._engine_type (target_values )
841847
842848 @final
@@ -2548,6 +2554,8 @@ def _is_all_dates(self) -> bool:
25482554 """
25492555 Whether or not the index values only consist of dates.
25502556 """
2557+ if self .dtype .kind == "b" :
2558+ return False
25512559 return is_datetime_array (ensure_object (self ._values ))
25522560
25532561 @cache_readonly
@@ -7048,7 +7056,7 @@ def _maybe_cast_data_without_dtype(
70487056 FutureWarning ,
70497057 stacklevel = 3 ,
70507058 )
7051- if result .dtype .kind in ["b" , " c" ]:
7059+ if result .dtype .kind in ["c" ]:
70527060 return subarr
70537061 result = ensure_wrapped_if_datetimelike (result )
70547062 return result
0 commit comments