98
98
is_float_dtype ,
99
99
is_hashable ,
100
100
is_integer ,
101
+ is_integer_dtype ,
101
102
is_interval_dtype ,
102
103
is_iterator ,
103
104
is_list_like ,
@@ -2200,7 +2201,7 @@ def is_boolean(self) -> bool:
2200
2201
2201
2202
See Also
2202
2203
--------
2203
- is_integer : Check if the Index only consists of integers.
2204
+ is_integer : Check if the Index only consists of integers (deprecated) .
2204
2205
is_floating : Check if the Index is a floating type.
2205
2206
is_numeric : Check if the Index only consists of numeric data.
2206
2207
is_object : Check if the Index is of the object dtype.
@@ -2228,6 +2229,9 @@ def is_integer(self) -> bool:
2228
2229
"""
2229
2230
Check if the Index only consists of integers.
2230
2231
2232
+ .. deprecated:: 2.0.0
2233
+ Use `pandas.api.types.is_integer_dtype` instead.
2234
+
2231
2235
Returns
2232
2236
-------
2233
2237
bool
@@ -2256,6 +2260,12 @@ def is_integer(self) -> bool:
2256
2260
>>> idx.is_integer()
2257
2261
False
2258
2262
"""
2263
+ warnings .warn (
2264
+ f"{ type (self ).__name__ } .is_integer is deprecated."
2265
+ "Use pandas.api.types.is_integer_dtype instead" ,
2266
+ FutureWarning ,
2267
+ stacklevel = find_stack_level (),
2268
+ )
2259
2269
return self .inferred_type in ["integer" ]
2260
2270
2261
2271
@final
@@ -2275,7 +2285,7 @@ def is_floating(self) -> bool:
2275
2285
See Also
2276
2286
--------
2277
2287
is_boolean : Check if the Index only consists of booleans.
2278
- is_integer : Check if the Index only consists of integers.
2288
+ is_integer : Check if the Index only consists of integers (deprecated) .
2279
2289
is_numeric : Check if the Index only consists of numeric data.
2280
2290
is_object : Check if the Index is of the object dtype.
2281
2291
is_categorical : Check if the Index holds categorical data.
@@ -2314,7 +2324,7 @@ def is_numeric(self) -> bool:
2314
2324
See Also
2315
2325
--------
2316
2326
is_boolean : Check if the Index only consists of booleans.
2317
- is_integer : Check if the Index only consists of integers.
2327
+ is_integer : Check if the Index only consists of integers (deprecated) .
2318
2328
is_floating : Check if the Index is a floating type.
2319
2329
is_object : Check if the Index is of the object dtype.
2320
2330
is_categorical : Check if the Index holds categorical data.
@@ -2357,7 +2367,7 @@ def is_object(self) -> bool:
2357
2367
See Also
2358
2368
--------
2359
2369
is_boolean : Check if the Index only consists of booleans.
2360
- is_integer : Check if the Index only consists of integers.
2370
+ is_integer : Check if the Index only consists of integers (deprecated) .
2361
2371
is_floating : Check if the Index is a floating type.
2362
2372
is_numeric : Check if the Index only consists of numeric data.
2363
2373
is_categorical : Check if the Index holds categorical data.
@@ -2398,7 +2408,7 @@ def is_categorical(self) -> bool:
2398
2408
--------
2399
2409
CategoricalIndex : Index for categorical data.
2400
2410
is_boolean : Check if the Index only consists of booleans.
2401
- is_integer : Check if the Index only consists of integers.
2411
+ is_integer : Check if the Index only consists of integers (deprecated) .
2402
2412
is_floating : Check if the Index is a floating type.
2403
2413
is_numeric : Check if the Index only consists of numeric data.
2404
2414
is_object : Check if the Index is of the object dtype.
@@ -2441,7 +2451,7 @@ def is_interval(self) -> bool:
2441
2451
--------
2442
2452
IntervalIndex : Index for Interval objects.
2443
2453
is_boolean : Check if the Index only consists of booleans.
2444
- is_integer : Check if the Index only consists of integers.
2454
+ is_integer : Check if the Index only consists of integers (deprecated) .
2445
2455
is_floating : Check if the Index is a floating type.
2446
2456
is_numeric : Check if the Index only consists of numeric data.
2447
2457
is_object : Check if the Index is of the object dtype.
@@ -3883,7 +3893,7 @@ def is_int(v):
3883
3893
3884
3894
if kind == "getitem" :
3885
3895
# called from the getitem slicers, validate that we are in fact integers
3886
- if self .is_integer ( ):
3896
+ if is_integer_dtype ( self .dtype ):
3887
3897
if is_frame :
3888
3898
# unambiguously positional, no deprecation
3889
3899
pass
@@ -3919,7 +3929,7 @@ def is_int(v):
3919
3929
FutureWarning ,
3920
3930
stacklevel = find_stack_level (),
3921
3931
)
3922
- if self .is_integer ( ) or is_index_slice :
3932
+ if is_integer_dtype ( self .dtype ) or is_index_slice :
3923
3933
# Note: these checks are redundant if we know is_index_slice
3924
3934
self ._validate_indexer ("slice" , key .start , "getitem" )
3925
3935
self ._validate_indexer ("slice" , key .stop , "getitem" )
0 commit comments