diff --git a/doc/source/user_guide/indexing.rst b/doc/source/user_guide/indexing.rst index 530fdfba7d12c..44e2d8daa4de0 100644 --- a/doc/source/user_guide/indexing.rst +++ b/doc/source/user_guide/indexing.rst @@ -422,6 +422,17 @@ above example, ``s.loc[1:6]`` would raise ``KeyError``. For the rationale behind this behavior, see :ref:`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 `. + .. _indexing.integer: Selection by position