@@ -2238,7 +2238,7 @@ def is_integer(self) -> bool:
2238
2238
is_floating : Check if the Index is a floating type.
2239
2239
is_numeric : Check if the Index only consists of numeric data.
2240
2240
is_object : Check if the Index is of the object dtype.
2241
- is_categorical : Check if the Index holds categorical data.
2241
+ is_categorical : Check if the Index holds categorical data (deprecated) .
2242
2242
is_interval : Check if the Index holds Interval objects.
2243
2243
2244
2244
Examples
@@ -2277,7 +2277,7 @@ def is_floating(self) -> bool:
2277
2277
is_integer : Check if the Index only consists of integers.
2278
2278
is_numeric : Check if the Index only consists of numeric data.
2279
2279
is_object : Check if the Index is of the object dtype.
2280
- is_categorical : Check if the Index holds categorical data.
2280
+ is_categorical : Check if the Index holds categorical data (deprecated) .
2281
2281
is_interval : Check if the Index holds Interval objects.
2282
2282
2283
2283
Examples
@@ -2316,7 +2316,7 @@ def is_numeric(self) -> bool:
2316
2316
is_integer : Check if the Index only consists of integers.
2317
2317
is_floating : Check if the Index is a floating type.
2318
2318
is_object : Check if the Index is of the object dtype.
2319
- is_categorical : Check if the Index holds categorical data.
2319
+ is_categorical : Check if the Index holds categorical data (deprecated) .
2320
2320
is_interval : Check if the Index holds Interval objects.
2321
2321
2322
2322
Examples
@@ -2359,7 +2359,7 @@ def is_object(self) -> bool:
2359
2359
is_integer : Check if the Index only consists of integers.
2360
2360
is_floating : Check if the Index is a floating type.
2361
2361
is_numeric : Check if the Index only consists of numeric data.
2362
- is_categorical : Check if the Index holds categorical data.
2362
+ is_categorical : Check if the Index holds categorical data (deprecated) .
2363
2363
is_interval : Check if the Index holds Interval objects.
2364
2364
2365
2365
Examples
@@ -2388,6 +2388,9 @@ def is_categorical(self) -> bool:
2388
2388
"""
2389
2389
Check if the Index holds categorical data.
2390
2390
2391
+ .. deprecated:: 2.0.0
2392
+ Use :meth:`pandas.api.types.is_categorical_dtype` instead.
2393
+
2391
2394
Returns
2392
2395
-------
2393
2396
bool
@@ -2424,6 +2427,12 @@ def is_categorical(self) -> bool:
2424
2427
>>> s.index.is_categorical()
2425
2428
False
2426
2429
"""
2430
+ warnings .warn (
2431
+ f"{ type (self ).__name__ } .is_categorical is deprecated."
2432
+ "Use pandas.api.types.is_categorical_dtype instead" ,
2433
+ FutureWarning ,
2434
+ stacklevel = find_stack_level (),
2435
+ )
2427
2436
return self .inferred_type in ["categorical" ]
2428
2437
2429
2438
@final
@@ -2444,7 +2453,7 @@ def is_interval(self) -> bool:
2444
2453
is_floating : Check if the Index is a floating type.
2445
2454
is_numeric : Check if the Index only consists of numeric data.
2446
2455
is_object : Check if the Index is of the object dtype.
2447
- is_categorical : Check if the Index holds categorical data.
2456
+ is_categorical : Check if the Index holds categorical data (deprecated) .
2448
2457
2449
2458
Examples
2450
2459
--------
@@ -5014,7 +5023,11 @@ def _can_hold_identifiers_and_holds_name(self, name) -> bool:
5014
5023
5015
5024
https://github.com/pandas-dev/pandas/issues/19764
5016
5025
"""
5017
- if self .is_object () or is_string_dtype (self .dtype ) or self .is_categorical ():
5026
+ if (
5027
+ self .is_object ()
5028
+ or is_string_dtype (self .dtype )
5029
+ or is_categorical_dtype (self )
5030
+ ):
5018
5031
return name in self
5019
5032
return False
5020
5033
0 commit comments