pandas.api.types.is_bool_dtype#
- pandas.api.types.is_bool_dtype(arr_or_dtype)[source]#
Check whether the provided array or dtype is of a boolean dtype.
This function verifies whether a given object is a boolean data type. The input can be an array or a dtype object. Accepted array types include instances of
np.array
,pd.Series
,pd.Index
, and similar array-like structures.- Parameters:
- arr_or_dtypearray-like or dtype
The array or dtype to check.
- Returns:
- boolean
Whether or not the array or dtype is of a boolean dtype.
See also
api.types.is_bool
Check if an object is a boolean.
Notes
An ExtensionArray is considered boolean when the
_is_boolean
attribute is set to True.Examples
>>> from pandas.api.types import is_bool_dtype >>> is_bool_dtype(str) False >>> is_bool_dtype(int) False >>> is_bool_dtype(bool) True >>> is_bool_dtype(np.bool_) True >>> is_bool_dtype(np.array(["a", "b"])) False >>> is_bool_dtype(pd.Series([1, 2])) False >>> is_bool_dtype(np.array([True, False])) True >>> is_bool_dtype(pd.Categorical([True, False])) True >>> is_bool_dtype(pd.arrays.SparseArray([True, False])) True