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 pandas-dev#36251
  • Loading branch information
junjunjunk committed Oct 2, 2020
1 parent 6fc17fa commit 0f2282e
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 labels is dupulicate labels,
an error will be raised. For instance, in the above example, ``s.loc[2:5]`` would raise ``KeyError``.

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

.. _indexing.integer:

Selection by position
Expand Down

0 comments on commit 0f2282e

Please sign in to comment.