@@ -2250,7 +2250,7 @@ def is_integer(self) -> bool:
2250
2250
is_floating : Check if the Index is a floating type (deprecated).
2251
2251
is_numeric : Check if the Index only consists of numeric data.
2252
2252
is_object : Check if the Index is of the object dtype.
2253
- is_categorical : Check if the Index holds categorical data.
2253
+ is_categorical : Check if the Index holds categorical data (deprecated) .
2254
2254
is_interval : Check if the Index holds Interval objects.
2255
2255
2256
2256
Examples
@@ -2298,7 +2298,7 @@ def is_floating(self) -> bool:
2298
2298
is_integer : Check if the Index only consists of integers (deprecated).
2299
2299
is_numeric : Check if the Index only consists of numeric data.
2300
2300
is_object : Check if the Index is of the object dtype.
2301
- is_categorical : Check if the Index holds categorical data.
2301
+ is_categorical : Check if the Index holds categorical data (deprecated) .
2302
2302
is_interval : Check if the Index holds Interval objects.
2303
2303
2304
2304
Examples
@@ -2343,7 +2343,7 @@ def is_numeric(self) -> bool:
2343
2343
is_integer : Check if the Index only consists of integers (deprecated).
2344
2344
is_floating : Check if the Index is a floating type (deprecated).
2345
2345
is_object : Check if the Index is of the object dtype.
2346
- is_categorical : Check if the Index holds categorical data.
2346
+ is_categorical : Check if the Index holds categorical data (deprecated) .
2347
2347
is_interval : Check if the Index holds Interval objects.
2348
2348
2349
2349
Examples
@@ -2386,7 +2386,7 @@ def is_object(self) -> bool:
2386
2386
is_integer : Check if the Index only consists of integers (deprecated).
2387
2387
is_floating : Check if the Index is a floating type (deprecated).
2388
2388
is_numeric : Check if the Index only consists of numeric data.
2389
- is_categorical : Check if the Index holds categorical data.
2389
+ is_categorical : Check if the Index holds categorical data (deprecated) .
2390
2390
is_interval : Check if the Index holds Interval objects.
2391
2391
2392
2392
Examples
@@ -2415,6 +2415,9 @@ def is_categorical(self) -> bool:
2415
2415
"""
2416
2416
Check if the Index holds categorical data.
2417
2417
2418
+ .. deprecated:: 2.0.0
2419
+ Use :meth:`pandas.api.types.is_categorical_dtype` instead.
2420
+
2418
2421
Returns
2419
2422
-------
2420
2423
bool
@@ -2451,6 +2454,13 @@ def is_categorical(self) -> bool:
2451
2454
>>> s.index.is_categorical()
2452
2455
False
2453
2456
"""
2457
+ warnings .warn (
2458
+ f"{ type (self ).__name__ } .is_categorical is deprecated."
2459
+ "Use pandas.api.types.is_categorical_dtype instead" ,
2460
+ FutureWarning ,
2461
+ stacklevel = find_stack_level (),
2462
+ )
2463
+
2454
2464
return self .inferred_type in ["categorical" ]
2455
2465
2456
2466
@final
@@ -2471,7 +2481,7 @@ def is_interval(self) -> bool:
2471
2481
is_floating : Check if the Index is a floating type (deprecated).
2472
2482
is_numeric : Check if the Index only consists of numeric data.
2473
2483
is_object : Check if the Index is of the object dtype.
2474
- is_categorical : Check if the Index holds categorical data.
2484
+ is_categorical : Check if the Index holds categorical data (deprecated) .
2475
2485
2476
2486
Examples
2477
2487
--------
@@ -5033,7 +5043,11 @@ def _can_hold_identifiers_and_holds_name(self, name) -> bool:
5033
5043
5034
5044
https://github.com/pandas-dev/pandas/issues/19764
5035
5045
"""
5036
- if self .is_object () or is_string_dtype (self .dtype ) or self .is_categorical ():
5046
+ if (
5047
+ self .is_object ()
5048
+ or is_string_dtype (self .dtype )
5049
+ or is_categorical_dtype (self .dtype )
5050
+ ):
5037
5051
return name in self
5038
5052
return False
5039
5053
0 commit comments