From 60d27be30c45304c3f4fab9491607e7e48bd3887 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Sun, 18 Feb 2024 23:07:28 +0100 Subject: [PATCH] Remove dtype inference on object dtype indexes for bool --- pandas/core/dtypes/common.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index 8eee15e13791a..9be03e6cc6119 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -30,7 +30,6 @@ PeriodDtype, SparseDtype, ) -from pandas.core.dtypes.generic import ABCIndex from pandas.core.dtypes.inference import ( is_array_like, is_bool, @@ -1235,21 +1234,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_)