-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Add examples to MultiIndex.slice_locs + note that index.slice requires #17799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC: Add examples to MultiIndex.slice_locs + note that index.slice requires #17799
Conversation
monotonic ordering
Codecov Report
@@ Coverage Diff @@
## master #17799 +/- ##
==========================================
- Coverage 91.24% 91.2% -0.05%
==========================================
Files 163 163
Lines 49971 49971
==========================================
- Hits 45597 45576 -21
- Misses 4374 4395 +21
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comments!
pandas/core/indexes/base.py
Outdated
@@ -3556,7 +3556,7 @@ def get_slice_bound(self, label, side, kind): | |||
|
|||
def slice_locs(self, start=None, end=None, step=None, kind=None): | |||
""" | |||
Compute slice locations for input labels. | |||
For an ordered index, compute slice locations for input labels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Index does not need to be ordered (it's only when there are duplicates that it has to be ordered I think). eg:
In [11]: pd.Index([1, 3, 4, 2]).slice_locs(1, 2)
Out[11]: (0, 4)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thanks for catching that. I've reworded.
pandas/core/indexes/multi.py
Outdated
|
||
Examples | ||
-------- | ||
mi = pd.MultiIndex.from_arrays([list('abbd'), list('deff')], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
>>>
...
notation for the examples
pandas/core/indexes/multi.py
Outdated
@@ -2015,6 +2042,8 @@ def get_loc(self, key, method=None): | |||
See also | |||
-------- | |||
Index.get_loc : get_loc method for (single-level) index. | |||
MultiIndex.slice_locs : Get slice location given startlabel(s) and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
startlabel -> start label
Commit added doing the requested changes. |
c84dd1c
to
1e5fd28
Compare
@topper-123 Thanks! |
Clarify
.slice_locs
and set up examples for how to use the method.Also, for
pd.Index
clarify that using.slice_locs
requires that the index is monotonic.