@@ -2193,6 +2193,9 @@ def is_boolean(self) -> bool:
2193
2193
"""
2194
2194
Check if the Index only consists of booleans.
2195
2195
2196
+ .. deprecated:: 2.0.0
2197
+ Use `pandas.api.types.is_bool_dtype` instead.
2198
+
2196
2199
Returns
2197
2200
-------
2198
2201
bool
@@ -2221,6 +2224,12 @@ def is_boolean(self) -> bool:
2221
2224
>>> idx.is_boolean()
2222
2225
False
2223
2226
"""
2227
+ warnings .warn (
2228
+ f"{ type (self ).__name__ } .is_boolean is deprecated."
2229
+ "Use pandas.api.types.is_bool_type instead" ,
2230
+ FutureWarning ,
2231
+ stacklevel = find_stack_level (),
2232
+ )
2224
2233
return self .inferred_type in ["boolean" ]
2225
2234
2226
2235
@final
@@ -2235,7 +2244,7 @@ def is_integer(self) -> bool:
2235
2244
2236
2245
See Also
2237
2246
--------
2238
- is_boolean : Check if the Index only consists of booleans.
2247
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2239
2248
is_floating : Check if the Index is a floating type.
2240
2249
is_numeric : Check if the Index only consists of numeric data.
2241
2250
is_object : Check if the Index is of the object dtype.
@@ -2274,7 +2283,7 @@ def is_floating(self) -> bool:
2274
2283
2275
2284
See Also
2276
2285
--------
2277
- is_boolean : Check if the Index only consists of booleans.
2286
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2278
2287
is_integer : Check if the Index only consists of integers.
2279
2288
is_numeric : Check if the Index only consists of numeric data.
2280
2289
is_object : Check if the Index is of the object dtype.
@@ -2313,7 +2322,7 @@ def is_numeric(self) -> bool:
2313
2322
2314
2323
See Also
2315
2324
--------
2316
- is_boolean : Check if the Index only consists of booleans.
2325
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2317
2326
is_integer : Check if the Index only consists of integers.
2318
2327
is_floating : Check if the Index is a floating type.
2319
2328
is_object : Check if the Index is of the object dtype.
@@ -2356,7 +2365,7 @@ def is_object(self) -> bool:
2356
2365
2357
2366
See Also
2358
2367
--------
2359
- is_boolean : Check if the Index only consists of booleans.
2368
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2360
2369
is_integer : Check if the Index only consists of integers.
2361
2370
is_floating : Check if the Index is a floating type.
2362
2371
is_numeric : Check if the Index only consists of numeric data.
@@ -2397,7 +2406,7 @@ def is_categorical(self) -> bool:
2397
2406
See Also
2398
2407
--------
2399
2408
CategoricalIndex : Index for categorical data.
2400
- is_boolean : Check if the Index only consists of booleans.
2409
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2401
2410
is_integer : Check if the Index only consists of integers.
2402
2411
is_floating : Check if the Index is a floating type.
2403
2412
is_numeric : Check if the Index only consists of numeric data.
@@ -2440,7 +2449,7 @@ def is_interval(self) -> bool:
2440
2449
See Also
2441
2450
--------
2442
2451
IntervalIndex : Index for Interval objects.
2443
- is_boolean : Check if the Index only consists of booleans.
2452
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2444
2453
is_integer : Check if the Index only consists of integers.
2445
2454
is_floating : Check if the Index is a floating type.
2446
2455
is_numeric : Check if the Index only consists of numeric data.
@@ -5855,8 +5864,8 @@ def _should_compare(self, other: Index) -> bool:
5855
5864
Check if `self == other` can ever have non-False entries.
5856
5865
"""
5857
5866
5858
- if (other . is_boolean ( ) and self .is_numeric ()) or (
5859
- self . is_boolean ( ) and other .is_numeric ()
5867
+ if (is_bool_dtype ( other ) and self .is_numeric ()) or (
5868
+ is_bool_dtype ( self ) and other .is_numeric ()
5860
5869
):
5861
5870
# GH#16877 Treat boolean labels passed to a numeric index as not
5862
5871
# found. Without this fix False and True would be treated as 0 and 1
0 commit comments