@@ -2192,6 +2192,9 @@ def is_boolean(self) -> bool:
2192
2192
"""
2193
2193
Check if the Index only consists of booleans.
2194
2194
2195
+ .. deprecated:: 2.0.0
2196
+ Use `pandas.api.types.is_bool_dtype` instead.
2197
+
2195
2198
Returns
2196
2199
-------
2197
2200
bool
@@ -2220,6 +2223,12 @@ def is_boolean(self) -> bool:
2220
2223
>>> idx.is_boolean()
2221
2224
False
2222
2225
"""
2226
+ warnings .warn (
2227
+ f"{ type (self ).__name__ } .is_boolean is deprecated. "
2228
+ "Use pandas.api.types.is_bool_type instead." ,
2229
+ FutureWarning ,
2230
+ stacklevel = find_stack_level (),
2231
+ )
2223
2232
return self .inferred_type in ["boolean" ]
2224
2233
2225
2234
@final
@@ -2237,7 +2246,7 @@ def is_integer(self) -> bool:
2237
2246
2238
2247
See Also
2239
2248
--------
2240
- is_boolean : Check if the Index only consists of booleans.
2249
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2241
2250
is_floating : Check if the Index is a floating type (deprecated).
2242
2251
is_numeric : Check if the Index only consists of numeric data.
2243
2252
is_object : Check if the Index is of the object dtype.
@@ -2285,7 +2294,7 @@ def is_floating(self) -> bool:
2285
2294
2286
2295
See Also
2287
2296
--------
2288
- is_boolean : Check if the Index only consists of booleans.
2297
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2289
2298
is_integer : Check if the Index only consists of integers (deprecated).
2290
2299
is_numeric : Check if the Index only consists of numeric data.
2291
2300
is_object : Check if the Index is of the object dtype.
@@ -2311,8 +2320,8 @@ def is_floating(self) -> bool:
2311
2320
False
2312
2321
"""
2313
2322
warnings .warn (
2314
- f"{ type (self ).__name__ } .is_floating is deprecated."
2315
- "Use pandas.api.types.is_float_dtype instead" ,
2323
+ f"{ type (self ).__name__ } .is_floating is deprecated. "
2324
+ "Use pandas.api.types.is_float_dtype instead. " ,
2316
2325
FutureWarning ,
2317
2326
stacklevel = find_stack_level (),
2318
2327
)
@@ -2330,7 +2339,7 @@ def is_numeric(self) -> bool:
2330
2339
2331
2340
See Also
2332
2341
--------
2333
- is_boolean : Check if the Index only consists of booleans.
2342
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2334
2343
is_integer : Check if the Index only consists of integers (deprecated).
2335
2344
is_floating : Check if the Index is a floating type (deprecated).
2336
2345
is_object : Check if the Index is of the object dtype.
@@ -2373,7 +2382,7 @@ def is_object(self) -> bool:
2373
2382
2374
2383
See Also
2375
2384
--------
2376
- is_boolean : Check if the Index only consists of booleans.
2385
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2377
2386
is_integer : Check if the Index only consists of integers (deprecated).
2378
2387
is_floating : Check if the Index is a floating type (deprecated).
2379
2388
is_numeric : Check if the Index only consists of numeric data.
@@ -2414,7 +2423,7 @@ def is_categorical(self) -> bool:
2414
2423
See Also
2415
2424
--------
2416
2425
CategoricalIndex : Index for categorical data.
2417
- is_boolean : Check if the Index only consists of booleans.
2426
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2418
2427
is_integer : Check if the Index only consists of integers (deprecated).
2419
2428
is_floating : Check if the Index is a floating type (deprecated).
2420
2429
is_numeric : Check if the Index only consists of numeric data.
@@ -2457,7 +2466,7 @@ def is_interval(self) -> bool:
2457
2466
See Also
2458
2467
--------
2459
2468
IntervalIndex : Index for Interval objects.
2460
- is_boolean : Check if the Index only consists of booleans.
2469
+ is_boolean : Check if the Index only consists of booleans (deprecated) .
2461
2470
is_integer : Check if the Index only consists of integers (deprecated).
2462
2471
is_floating : Check if the Index is a floating type (deprecated).
2463
2472
is_numeric : Check if the Index only consists of numeric data.
@@ -2478,12 +2487,28 @@ def is_interval(self) -> bool:
2478
2487
return self .inferred_type in ["interval" ]
2479
2488
2480
2489
@final
2481
- def holds_integer (self ) -> bool :
2490
+ def _holds_integer (self ) -> bool :
2482
2491
"""
2483
2492
Whether the type is an integer type.
2484
2493
"""
2485
2494
return self .inferred_type in ["integer" , "mixed-integer" ]
2486
2495
2496
+ @final
2497
+ def holds_integer (self ) -> bool :
2498
+ """
2499
+ Whether the type is an integer type.
2500
+
2501
+ .. deprecated:: 2.0.0
2502
+ Use `pandas.api.types.infer_dtype` instead
2503
+ """
2504
+ warnings .warn (
2505
+ f"{ type (self ).__name__ } .holds_integer is deprecated. "
2506
+ "Use pandas.api.types.infer_dtype instead." ,
2507
+ FutureWarning ,
2508
+ stacklevel = find_stack_level (),
2509
+ )
2510
+ return self ._holds_integer ()
2511
+
2487
2512
@cache_readonly
2488
2513
def inferred_type (self ) -> str_t :
2489
2514
"""
@@ -5528,7 +5553,7 @@ def _should_fallback_to_positional(self) -> bool:
5528
5553
"""
5529
5554
Should an integer key be treated as positional?
5530
5555
"""
5531
- return not self .holds_integer ()
5556
+ return not self ._holds_integer ()
5532
5557
5533
5558
_index_shared_docs [
5534
5559
"get_indexer_non_unique"
@@ -5874,8 +5899,8 @@ def _should_compare(self, other: Index) -> bool:
5874
5899
Check if `self == other` can ever have non-False entries.
5875
5900
"""
5876
5901
5877
- if (other . is_boolean ( ) and self .is_numeric ()) or (
5878
- self . is_boolean ( ) and other .is_numeric ()
5902
+ if (is_bool_dtype ( other ) and self .is_numeric ()) or (
5903
+ is_bool_dtype ( self ) and other .is_numeric ()
5879
5904
):
5880
5905
# GH#16877 Treat boolean labels passed to a numeric index as not
5881
5906
# found. Without this fix False and True would be treated as 0 and 1
0 commit comments