-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Examples of monotonic/non-monotonic label-based indexing #12522
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
Conversation
@@ -242,6 +242,57 @@ Label-based slicing conventions | |||
Non-monotonic indexes require exact matches | |||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |||
|
|||
If the index of a ``DataFrame`` is montonically increasing or decreasing, then the bounds |
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.
typo in 'montonically'
@nileracecrew Thanks for this nice contribution to the docs! (that title was indeed missing an explanation ;-)) It is certainly good to keep it here, but we maybe should also consider to include a similar explanation in the indexing docs itself. |
You're welcoem @jorisvandenbossche. Seems like this behavior is most likely to show up when you have other problems (in my case corrupted data, as well as an in another issue I found), but it is surprising. I made the suggested edits and re-committed. |
instead a empty frame use a range for number (range(6)) |
Sorry, I don't quite understand your meaning. Do you mean fill the example DataFrame with numbers, or use range(6) as an index instead of the empty DataFrame example, or something else? |
fill with numbers |
@nileracecrew : If I'm not mistaken (unless the tests do check these files), since your fixes are purely documentation related, you should put [ci skip] in your commit message because you aren't changing any code. Every time you make a change to your PR, you are adding another build to Travis (you currently have five). Unless these |
If the index of a ``DataFrame`` is monotonically increasing or decreasing, then the bounds | ||
of a label-based slice can be outside the range of the index, much like slice indexing a | ||
normal Python ``list``. | ||
|
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.
hmm actually what I mean is we need to more references to this section as this is certainly easy to miss. maybe can do that in antother PR though.
>>> df_monotonic_index = pd.DataFrame(index=[2,3,3,4,5], columns=['data'], data=range(5)) | ||
|
||
# no rows 0 or 1, but still returns rows 2, 3 (both of them), and 4: | ||
>>> df_monotonic_index.loc[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.
actually make these all ipython blocks rather than code-blocks.
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.
In this case it makes sense to use code blocks I think, as below there are some error messages shown (and they don't need to be shown fully).
But, maybe use IPython prompts for uniformity with the rest of the document?
pls squash when you update |
Is there a quick way to render a single .rst file to see the output? GitHub doesn't render the ipython blocks. |
sorry, didn't mean to push that here |
thanks! |
Just ran into this gotcha and almost filed it as a bug report. Added a few examples to fill in the section header.