File tree 1 file changed +18
-7
lines changed
1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -415,20 +415,29 @@ For getting a cross section using an integer position (equiv to ``df.xs(1)``)
415
415
416
416
df1.iloc[1 ]
417
417
418
- There is one significant departure from standard python/numpy slicing semantics.
419
- python/numpy allow slicing past the end of an array without an associated error.
418
+ Out of range slice indexes are handled gracefully just as in Python/Numpy.
420
419
421
420
.. ipython :: python
422
421
423
422
# these are allowed in python/numpy.
423
+ # Only works in Pandas starting from v0.14.0.
424
424
x = list (' abcdef' )
425
+ x
425
426
x[4 :10 ]
426
427
x[8 :10 ]
428
+ s = Series(x)
429
+ s
430
+ s.iloc[4 :10 ]
431
+ s.iloc[8 :10 ]
427
432
428
- - as of v0.14.0, ``iloc `` will now accept out-of-bounds indexers for slices, e.g. a value that exceeds the length of the object being
429
- indexed. These will be excluded. This will make pandas conform more with pandas/numpy indexing of out-of-bounds
430
- values. A single indexer / list of indexers that is out-of-bounds will still raise
431
- ``IndexError `` (:issue: `6296 `, :issue: `6299 `). This could result in an empty axis (e.g. an empty DataFrame being returned)
433
+ .. note ::
434
+
435
+ Prior to v0.14.0, ``iloc `` would not accept out of bounds indexers for
436
+ slices, e.g. a value that exceeds the length of the object being indexed.
437
+
438
+
439
+ Note that this could result in an empty axis (e.g. an empty DataFrame being
440
+ returned)
432
441
433
442
.. ipython :: python
434
443
@@ -438,7 +447,9 @@ python/numpy allow slicing past the end of an array without an associated error.
438
447
dfl.iloc[:,1 :3 ]
439
448
dfl.iloc[4 :6 ]
440
449
441
- These are out-of-bounds selections
450
+ A single indexer that is out of bounds will raise an ``IndexError ``.
451
+ A list of indexers where any element is out of bounds will raise an
452
+ ``IndexError ``
442
453
443
454
.. code-block :: python
444
455
You can’t perform that action at this time.
0 commit comments