@@ -481,6 +481,10 @@ def __new__(
481
481
if data .dtype .kind in ["i" , "u" , "f" ]:
482
482
# maybe coerce to a sub-class
483
483
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 )
484
488
else :
485
489
arr = com .asarray_tuplesafe (data , dtype = np .dtype ("object" ))
486
490
@@ -672,7 +676,7 @@ def _with_infer(cls, *args, **kwargs):
672
676
# "Union[ExtensionArray, ndarray[Any, Any]]"; expected
673
677
# "ndarray[Any, Any]"
674
678
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" ]:
676
680
return Index (values , name = result .name )
677
681
678
682
return result
@@ -837,6 +841,8 @@ def _engine(self) -> libindex.IndexEngine:
837
841
# to avoid a reference cycle, bind `target_values` to a local variable, so
838
842
# `self` is not passed into the lambda.
839
843
target_values = self ._get_engine_target ()
844
+ if target_values .dtype == bool :
845
+ return libindex .BoolEngine (target_values )
840
846
return self ._engine_type (target_values )
841
847
842
848
@final
@@ -2548,6 +2554,8 @@ def _is_all_dates(self) -> bool:
2548
2554
"""
2549
2555
Whether or not the index values only consist of dates.
2550
2556
"""
2557
+ if self .dtype .kind == "b" :
2558
+ return False
2551
2559
return is_datetime_array (ensure_object (self ._values ))
2552
2560
2553
2561
@cache_readonly
@@ -7048,7 +7056,7 @@ def _maybe_cast_data_without_dtype(
7048
7056
FutureWarning ,
7049
7057
stacklevel = 3 ,
7050
7058
)
7051
- if result .dtype .kind in ["b" , " c" ]:
7059
+ if result .dtype .kind in ["c" ]:
7052
7060
return subarr
7053
7061
result = ensure_wrapped_if_datetimelike (result )
7054
7062
return result
0 commit comments