-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
DOC: Updating pandas.Interval docstring #20057
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
Changes from 1 commit
eb8ce9f
e8cbf0b
080654d
f302acc
713d975
a0db247
7db6817
5a6727a
c1d7265
45f7f3b
4682386
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,26 +81,45 @@ cdef class Interval(IntervalMixin): | |
|
||
Parameters | ||
---------- | ||
left : value | ||
Left bound for the interval | ||
right : value | ||
Right bound for the interval | ||
left : orderable object | ||
Left bound for the interval. | ||
right : orderable object | ||
Right bound for the interval. | ||
closed : {'left', 'right', 'both', 'neither'}, default 'right' | ||
Whether the interval is closed on the left-side, right-side, both or | ||
neither | ||
neither. | ||
|
||
Notes | ||
----- | ||
You must be able to compare the parameters **left** and **right**, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use single backticks to refer to the keywords? (like |
||
and they must satisfy **left <= right**. | ||
|
||
Examples | ||
-------- | ||
The examples below show how you can build Intervals of various types | ||
of elements. In particular a numeric interval, a time interval and | ||
finally a string interval. Given an Interval you can check whether | ||
an element belongs to it. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general, I think it can be easier to follow to put some of those explanations between the examples, instead of first all explanation and then all examples. |
||
|
||
>>> iv = pd.Interval(left=0, right=5) | ||
>>> iv | ||
Interval(0, 5, closed='right') | ||
>>> 2.5 in iv | ||
True | ||
|
||
>>> shifted_iv = iv + 3 | ||
>>> shifted_iv | ||
Interval(3, 8, closed='right') | ||
|
||
>>> year_2017 = pd.Interval(pd.Timestamp('2017-01-01'), | ||
... pd.Timestamp('2017-12-31'), closed='both') | ||
>>> pd.Timestamp('2017-01-01 00:00') in year_2017 | ||
True | ||
>>> year_2017.length | ||
Timedelta('364 days 00:00:00') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be nice to change year_2017 = pd.Interval(pd.Timestamp('2017-01-01'),
pd.Timestamp('2018-01-01'), closed='left') That seems like a more accurate representation of a year, since the current version doesn't include anything beyond |
||
|
||
>>> volume_1 = pd.Interval('Ant','Dog',closed='both') | ||
>>> 'Bee' in volume_1 | ||
True | ||
|
||
See Also | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add Period here as well (its pretty much a time based interval) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To add a couple of points here: |
||
-------- | ||
|
@@ -283,4 +302,4 @@ cpdef intervals_to_interval_bounds(ndarray intervals): | |
|
||
return left, right, closed | ||
|
||
include "intervaltree.pxi" | ||
include "intervaltree.pxi" |
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.
maybe 'scalar' instead of object? To make clear an array-like is not accepted?