Skip to content

Commit 1e5fd28

Browse files
author
tp
committed
clarify that slice_locs also works with unique index
1 parent 2874a9e commit 1e5fd28

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

pandas/core/indexes/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3556,7 +3556,7 @@ def get_slice_bound(self, label, side, kind):
35563556

35573557
def slice_locs(self, start=None, end=None, step=None, kind=None):
35583558
"""
3559-
For an ordered index, compute slice locations for input labels.
3559+
Compute slice locations for input labels.
35603560
35613561
Parameters
35623562
----------
@@ -3574,7 +3574,7 @@ def slice_locs(self, start=None, end=None, step=None, kind=None):
35743574
35753575
Notes
35763576
-----
3577-
This method only works if the index is monotonic.
3577+
This method only works if the index is monotonic or unique.
35783578
35793579
Examples
35803580
---------

pandas/core/indexes/multi.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1952,19 +1952,19 @@ def slice_locs(self, start=None, end=None, step=None, kind=None):
19521952
19531953
Examples
19541954
--------
1955-
mi = pd.MultiIndex.from_arrays([list('abbd'), list('deff')],
1956-
names=['A', 'B'])
1955+
>>> mi = pd.MultiIndex.from_arrays([list('abbd'), list('deff')],
1956+
... names=['A', 'B'])
19571957
19581958
Get the slice locations from the beginning of 'b' in the first level
19591959
until the end of the multiindex:
19601960
1961-
mi.slice_locs(start='b')
1961+
>>> mi.slice_locs(start='b')
19621962
(1, 4)
19631963
19641964
Like above, but stop at the end of 'b' in the first level and 'f' in
19651965
the second level:
19661966
1967-
mi.slice_locs(start='b', end=('b', 'f'))
1967+
>>> mi.slice_locs(start='b', end=('b', 'f'))
19681968
(1, 3)
19691969
19701970
See Also
@@ -2042,8 +2042,8 @@ def get_loc(self, key, method=None):
20422042
See also
20432043
--------
20442044
Index.get_loc : get_loc method for (single-level) index.
2045-
MultiIndex.slice_locs : Get slice location given startlabel(s) and
2046-
endlabel(s).
2045+
MultiIndex.slice_locs : Get slice location given start label(s) and
2046+
end label(s).
20472047
MultiIndex.get_locs : Get location for a label/slice/list/mask or a
20482048
sequence of such.
20492049
"""
@@ -2397,8 +2397,8 @@ def get_locs(self, seq):
23972397
See also
23982398
--------
23992399
MultiIndex.get_loc : Get location for a label or a tuple of labels.
2400-
MultiIndex.slice_locs : Get slice location given startlabel(s) and
2401-
endlabel(s).
2400+
MultiIndex.slice_locs : Get slice location given start label(s) and
2401+
end label(s).
24022402
"""
24032403

24042404
# must be lexsorted to at least as many levels

0 commit comments

Comments
 (0)