Skip to content

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

Merged

Conversation

topper-123
Copy link
Contributor

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.

@codecov
Copy link

codecov bot commented Oct 5, 2017

Codecov Report

Merging #17799 into master will decrease coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 89% <ø> (-0.03%) ⬇️
#single 40.24% <ø> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/multi.py 96.39% <ø> (ø) ⬆️
pandas/core/indexes/base.py 96.46% <ø> (ø) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/plotting/_converter.py 63.38% <0%> (-1.82%) ⬇️
pandas/core/frame.py 97.74% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5653fe4...d41388b. Read the comment docs.

@jorisvandenbossche jorisvandenbossche added this to the 0.21.0 milestone Oct 6, 2017
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments!

@@ -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.
Copy link
Member

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)

Copy link
Contributor Author

@topper-123 topper-123 Oct 6, 2017

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.


Examples
--------
mi = pd.MultiIndex.from_arrays([list('abbd'), list('deff')],
Copy link
Member

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

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

startlabel -> start label

@topper-123
Copy link
Contributor Author

Commit added doing the requested changes.

@topper-123 topper-123 force-pushed the MultiIndex.slice_locs branch from c84dd1c to 1e5fd28 Compare October 6, 2017 09:45
@jorisvandenbossche jorisvandenbossche merged commit 4379d04 into pandas-dev:master Oct 6, 2017
@jorisvandenbossche
Copy link
Member

@topper-123 Thanks!

@topper-123 topper-123 deleted the MultiIndex.slice_locs branch October 9, 2017 21:00
ghost pushed a commit to reef-technologies/pandas that referenced this pull request Oct 16, 2017
alanbato pushed a commit to alanbato/pandas that referenced this pull request Nov 10, 2017
No-Stream pushed a commit to No-Stream/pandas that referenced this pull request Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants