@@ -220,7 +220,7 @@ def _convert_to_indexer(self, obj, axis=0):
220
220
is_int_index = _is_integer_index (labels )
221
221
if isinstance (obj , slice ):
222
222
223
- int_slice = _is_integer_slice (obj )
223
+ int_slice = _is_index_slice (obj )
224
224
null_slice = obj .start is None and obj .stop is None
225
225
# could have integers in the first level of the MultiIndex
226
226
position_slice = (int_slice
@@ -234,7 +234,7 @@ def _convert_to_indexer(self, obj, axis=0):
234
234
i , j = labels .slice_locs (obj .start , obj .stop )
235
235
slicer = slice (i , j , obj .step )
236
236
except Exception :
237
- if _is_integer_slice (obj ):
237
+ if _is_index_slice (obj ):
238
238
if labels .inferred_type == 'integer' :
239
239
raise
240
240
slicer = obj
@@ -276,7 +276,7 @@ def _get_slice_axis(self, slice_obj, axis=0):
276
276
axis_name = obj ._get_axis_name (axis )
277
277
labels = getattr (obj , axis_name )
278
278
279
- int_slice = _is_integer_slice (slice_obj )
279
+ int_slice = _is_index_slice (slice_obj )
280
280
281
281
null_slice = slice_obj .start is None and slice_obj .stop is None
282
282
# could have integers in the first level of the MultiIndex
@@ -289,7 +289,7 @@ def _get_slice_axis(self, slice_obj, axis=0):
289
289
i , j = labels .slice_locs (slice_obj .start , slice_obj .stop )
290
290
slicer = slice (i , j , slice_obj .step )
291
291
except Exception :
292
- if _is_integer_slice (slice_obj ):
292
+ if _is_index_slice (slice_obj ):
293
293
if labels .inferred_type == 'integer' :
294
294
raise
295
295
slicer = slice_obj
@@ -301,9 +301,12 @@ def _get_slice_axis(self, slice_obj, axis=0):
301
301
302
302
return self ._slice (slicer , axis = axis )
303
303
304
- def _is_integer_slice (obj ):
304
+ def _is_index_slice (obj ):
305
+ def _is_valid_index (x ):
306
+ return com .is_integer (x ) or com .is_float (x ) and np .allclose (x , int (x ))
307
+
305
308
def _crit (v ):
306
- return v is None or com . is_integer (v )
309
+ return v is None or _is_valid_index (v )
307
310
308
311
both_none = obj .start is None and obj .stop is None
309
312
0 commit comments