Skip to content

Commit

Permalink
DOC: add example & prose of slicing with labels when index has duplic…
Browse files Browse the repository at this point in the history
…ate labels (#36814)

* DOC: add example & prose of slicing with labels when index has duplicate labels #36251

* DOC: proofread the sentence.

Co-authored-by: Jun Kudo <jun-lab@junnoMacBook-Pro.local>
  • Loading branch information
junjunjunk and Jun Kudo committed Nov 5, 2020
1 parent 22de62c commit 31db14c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions doc/source/user_guide/indexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,17 @@ above example, ``s.loc[1:6]`` would raise ``KeyError``.
For the rationale behind this behavior, see
:ref:`Endpoints are inclusive <advanced.endpoints_are_inclusive>`.

.. ipython:: python
s = pd.Series(list('abcdef'), index=[0, 3, 2, 5, 4, 2])
s.loc[3:5]
Also, if the index has duplicate labels *and* either the start or the stop label is dupulicated,
an error will be raised. For instance, in the above example, ``s.loc[2:5]`` would raise a ``KeyError``.

For more information about duplicate labels, see
:ref:`Duplicate Labels <duplicates>`.

.. _indexing.integer:

Selection by position
Expand Down

0 comments on commit 31db14c

Please sign in to comment.