Skip to content

Remove dtype inference on object dtype indexes for bool #57492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
PeriodDtype,
SparseDtype,
)
from pandas.core.dtypes.generic import ABCIndex
from pandas.core.dtypes.inference import (
is_array_like,
is_bool,
Expand Down Expand Up @@ -1413,21 +1412,7 @@ def is_bool_dtype(arr_or_dtype) -> bool:
arr_or_dtype = dtype.categories
# now we use the special definition for Index

if isinstance(arr_or_dtype, ABCIndex):
# Allow Index[object] that is all-bools or Index["boolean"]
if arr_or_dtype.inferred_type == "boolean":
if not is_bool_dtype(arr_or_dtype.dtype):
# GH#52680
warnings.warn(
"The behavior of is_bool_dtype with an object-dtype Index "
"of bool objects is deprecated. In a future version, "
"this will return False. Cast the Index to a bool dtype instead.",
DeprecationWarning,
stacklevel=2,
)
return True
return False
elif isinstance(dtype, ExtensionDtype):
if isinstance(dtype, ExtensionDtype):
return getattr(dtype, "_is_boolean", False)

return issubclass(dtype.type, np.bool_)
Expand Down