Skip to content

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

Closed
wants to merge 2 commits into from

Conversation

nileracecrew
Copy link
Contributor

Just ran into this gotcha and almost filed it as a bug report. Added a few examples to fill in the section header.

@nileracecrew nileracecrew changed the title Examples of monotonic/non-monotonic label-based indexing DOC: Examples of monotonic/non-monotonic label-based indexing Mar 3, 2016
@@ -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
Copy link
Member

Choose a reason for hiding this comment

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

typo in 'montonically'

@jorisvandenbossche
Copy link
Member

@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.

@nileracecrew
Copy link
Contributor Author

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.

@jreback
Copy link
Contributor

jreback commented Mar 4, 2016

instead a empty frame use a range for number (range(6))

@nileracecrew
Copy link
Contributor Author

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?

@jreback
Copy link
Contributor

jreback commented Mar 4, 2016

fill with numbers

@gfyoung
Copy link
Member

gfyoung commented Mar 4, 2016

@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 .rst files are checked, I would suggest if someone could cancel all of your builds and you could put that "ci skip" tag in your commit.

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``.

Copy link
Contributor

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.

@jreback jreback added this to the 0.18.0 milestone Mar 5, 2016
>>> 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, :]
Copy link
Contributor

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.

Copy link
Member

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?

@jreback
Copy link
Contributor

jreback commented Mar 5, 2016

pls squash when you update

@jreback jreback modified the milestones: 0.18.1, 0.18.0 Mar 5, 2016
@nileracecrew
Copy link
Contributor Author

Is there a quick way to render a single .rst file to see the output? GitHub doesn't render the ipython blocks.

@nileracecrew
Copy link
Contributor Author

sorry, didn't mean to push that here

@jreback jreback closed this in f6d0d08 Apr 17, 2016
@jreback
Copy link
Contributor

jreback commented Apr 17, 2016

thanks!

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.

4 participants