Skip to content

Commit 60d27be

Browse files
committed
Remove dtype inference on object dtype indexes for bool
1 parent abc3efb commit 60d27be

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

pandas/core/dtypes/common.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
PeriodDtype,
3131
SparseDtype,
3232
)
33-
from pandas.core.dtypes.generic import ABCIndex
3433
from pandas.core.dtypes.inference import (
3534
is_array_like,
3635
is_bool,
@@ -1235,21 +1234,7 @@ def is_bool_dtype(arr_or_dtype) -> bool:
12351234
arr_or_dtype = dtype.categories
12361235
# now we use the special definition for Index
12371236

1238-
if isinstance(arr_or_dtype, ABCIndex):
1239-
# Allow Index[object] that is all-bools or Index["boolean"]
1240-
if arr_or_dtype.inferred_type == "boolean":
1241-
if not is_bool_dtype(arr_or_dtype.dtype):
1242-
# GH#52680
1243-
warnings.warn(
1244-
"The behavior of is_bool_dtype with an object-dtype Index "
1245-
"of bool objects is deprecated. In a future version, "
1246-
"this will return False. Cast the Index to a bool dtype instead.",
1247-
DeprecationWarning,
1248-
stacklevel=2,
1249-
)
1250-
return True
1251-
return False
1252-
elif isinstance(dtype, ExtensionDtype):
1237+
if isinstance(dtype, ExtensionDtype):
12531238
return getattr(dtype, "_is_boolean", False)
12541239

12551240
return issubclass(dtype.type, np.bool_)

0 commit comments

Comments
 (0)