@@ -2182,6 +2182,9 @@ def is_boolean(self) -> bool:
2182
2182
"""
2183
2183
Check if the Index only consists of booleans.
2184
2184
2185
+ .. deprecated:: 2.0.0
2186
+ Use `pandas.api.types.is_bool_dtype` instead.
2187
+
2185
2188
Returns
2186
2189
-------
2187
2190
bool
@@ -2210,6 +2213,12 @@ def is_boolean(self) -> bool:
2210
2213
>>> idx.is_boolean()
2211
2214
False
2212
2215
"""
2216
+ warnings .warn (
2217
+ f"{ type (self ).__name__ } .is_boolean is deprecated."
2218
+ "Use pandas.api.types.is_bool_type instead" ,
2219
+ FutureWarning ,
2220
+ stacklevel = find_stack_level (),
2221
+ )
2213
2222
return self .inferred_type in ["boolean" ]
2214
2223
2215
2224
@final
@@ -2227,7 +2236,7 @@ def is_integer(self) -> bool:
2227
2236
2228
2237
See Also
2229
2238
--------
2230
- is_boolean : Check if the Index only consists of booleans.
2239
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2231
2240
is_floating : Check if the Index is a floating type (deprecated).
2232
2241
is_numeric : Check if the Index only consists of numeric data.
2233
2242
is_object : Check if the Index is of the object dtype.
@@ -2275,7 +2284,7 @@ def is_floating(self) -> bool:
2275
2284
2276
2285
See Also
2277
2286
--------
2278
- is_boolean : Check if the Index only consists of booleans.
2287
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2279
2288
is_integer : Check if the Index only consists of integers (deprecated).
2280
2289
is_numeric : Check if the Index only consists of numeric data.
2281
2290
is_object : Check if the Index is of the object dtype.
@@ -2320,7 +2329,7 @@ def is_numeric(self) -> bool:
2320
2329
2321
2330
See Also
2322
2331
--------
2323
- is_boolean : Check if the Index only consists of booleans.
2332
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2324
2333
is_integer : Check if the Index only consists of integers (deprecated).
2325
2334
is_floating : Check if the Index is a floating type (deprecated).
2326
2335
is_object : Check if the Index is of the object dtype.
@@ -2363,7 +2372,7 @@ def is_object(self) -> bool:
2363
2372
2364
2373
See Also
2365
2374
--------
2366
- is_boolean : Check if the Index only consists of booleans.
2375
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2367
2376
is_integer : Check if the Index only consists of integers (deprecated).
2368
2377
is_floating : Check if the Index is a floating type (deprecated).
2369
2378
is_numeric : Check if the Index only consists of numeric data.
@@ -2404,7 +2413,7 @@ def is_categorical(self) -> bool:
2404
2413
See Also
2405
2414
--------
2406
2415
CategoricalIndex : Index for categorical data.
2407
- is_boolean : Check if the Index only consists of booleans.
2416
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2408
2417
is_integer : Check if the Index only consists of integers (deprecated).
2409
2418
is_floating : Check if the Index is a floating type (deprecated).
2410
2419
is_numeric : Check if the Index only consists of numeric data.
@@ -2447,7 +2456,7 @@ def is_interval(self) -> bool:
2447
2456
See Also
2448
2457
--------
2449
2458
IntervalIndex : Index for Interval objects.
2450
- is_boolean : Check if the Index only consists of booleans.
2459
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2451
2460
is_integer : Check if the Index only consists of integers (deprecated).
2452
2461
is_floating : Check if the Index is a floating type (deprecated).
2453
2462
is_numeric : Check if the Index only consists of numeric data.
@@ -5863,8 +5872,8 @@ def _should_compare(self, other: Index) -> bool:
5863
5872
Check if `self == other` can ever have non-False entries.
5864
5873
"""
5865
5874
5866
- if (other . is_boolean ( ) and self .is_numeric ()) or (
5867
- self . is_boolean ( ) and other .is_numeric ()
5875
+ if (is_bool_dtype ( other ) and self .is_numeric ()) or (
5876
+ is_bool_dtype ( self ) and other .is_numeric ()
5868
5877
):
5869
5878
# GH#16877 Treat boolean labels passed to a numeric index as not
5870
5879
# found. Without this fix False and True would be treated as 0 and 1
0 commit comments