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 ,
@@ -2188,7 +2189,7 @@ def is_boolean(self) -> bool:
2188
2189
2189
2190
See Also
2190
2191
--------
2191
- is_integer : Check if the Index only consists of integers.
2192
+ is_integer : Check if the Index only consists of integers (deprecated) .
2192
2193
is_floating : Check if the Index is a floating type (deprecated).
2193
2194
is_numeric : Check if the Index only consists of numeric data.
2194
2195
is_object : Check if the Index is of the object dtype.
@@ -2216,6 +2217,9 @@ def is_integer(self) -> bool:
2216
2217
"""
2217
2218
Check if the Index only consists of integers.
2218
2219
2220
+ .. deprecated:: 2.0.0
2221
+ Use `pandas.api.types.is_integer_dtype` instead.
2222
+
2219
2223
Returns
2220
2224
-------
2221
2225
bool
@@ -2244,6 +2248,12 @@ def is_integer(self) -> bool:
2244
2248
>>> idx.is_integer()
2245
2249
False
2246
2250
"""
2251
+ warnings .warn (
2252
+ f"{ type (self ).__name__ } .is_integer is deprecated. "
2253
+ "Use pandas.api.types.is_integer_dtype instead." ,
2254
+ FutureWarning ,
2255
+ stacklevel = find_stack_level (),
2256
+ )
2247
2257
return self .inferred_type in ["integer" ]
2248
2258
2249
2259
@final
@@ -2266,7 +2276,7 @@ def is_floating(self) -> bool:
2266
2276
See Also
2267
2277
--------
2268
2278
is_boolean : Check if the Index only consists of booleans.
2269
- is_integer : Check if the Index only consists of integers.
2279
+ is_integer : Check if the Index only consists of integers (deprecated) .
2270
2280
is_numeric : Check if the Index only consists of numeric data.
2271
2281
is_object : Check if the Index is of the object dtype.
2272
2282
is_categorical : Check if the Index holds categorical data.
@@ -2311,7 +2321,7 @@ def is_numeric(self) -> bool:
2311
2321
See Also
2312
2322
--------
2313
2323
is_boolean : Check if the Index only consists of booleans.
2314
- is_integer : Check if the Index only consists of integers.
2324
+ is_integer : Check if the Index only consists of integers (deprecated) .
2315
2325
is_floating : Check if the Index is a floating type (deprecated).
2316
2326
is_object : Check if the Index is of the object dtype.
2317
2327
is_categorical : Check if the Index holds categorical data.
@@ -2354,7 +2364,7 @@ def is_object(self) -> bool:
2354
2364
See Also
2355
2365
--------
2356
2366
is_boolean : Check if the Index only consists of booleans.
2357
- is_integer : Check if the Index only consists of integers.
2367
+ is_integer : Check if the Index only consists of integers (deprecated) .
2358
2368
is_floating : Check if the Index is a floating type (deprecated).
2359
2369
is_numeric : Check if the Index only consists of numeric data.
2360
2370
is_categorical : Check if the Index holds categorical data.
@@ -2395,7 +2405,7 @@ def is_categorical(self) -> bool:
2395
2405
--------
2396
2406
CategoricalIndex : Index for categorical data.
2397
2407
is_boolean : Check if the Index only consists of booleans.
2398
- is_integer : Check if the Index only consists of integers.
2408
+ is_integer : Check if the Index only consists of integers (deprecated) .
2399
2409
is_floating : Check if the Index is a floating type (deprecated).
2400
2410
is_numeric : Check if the Index only consists of numeric data.
2401
2411
is_object : Check if the Index is of the object dtype.
@@ -2438,7 +2448,7 @@ def is_interval(self) -> bool:
2438
2448
--------
2439
2449
IntervalIndex : Index for Interval objects.
2440
2450
is_boolean : Check if the Index only consists of booleans.
2441
- is_integer : Check if the Index only consists of integers.
2451
+ is_integer : Check if the Index only consists of integers (deprecated) .
2442
2452
is_floating : Check if the Index is a floating type (deprecated).
2443
2453
is_numeric : Check if the Index only consists of numeric data.
2444
2454
is_object : Check if the Index is of the object dtype.
@@ -3877,7 +3887,7 @@ def is_int(v):
3877
3887
3878
3888
if kind == "getitem" :
3879
3889
# called from the getitem slicers, validate that we are in fact integers
3880
- if self .is_integer ( ) or is_index_slice :
3890
+ if is_integer_dtype ( self .dtype ) or is_index_slice :
3881
3891
# Note: these checks are redundant if we know is_index_slice
3882
3892
self ._validate_indexer ("slice" , key .start , "getitem" )
3883
3893
self ._validate_indexer ("slice" , key .stop , "getitem" )
0 commit comments