-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update the Series.between docstring #20443
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
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 |
---|---|---|
|
@@ -3511,19 +3511,64 @@ def isin(self, values): | |
|
||
def between(self, left, right, inclusive=True): | ||
""" | ||
Return boolean Series equivalent to left <= series <= right. NA values | ||
will be treated as False | ||
Return boolean Series equivalent to left <= series <= right. | ||
|
||
This function returns a boolean vector containing `True` wherever the | ||
corresponding Series element is between the boundary values `left` and | ||
`right`. NA values are treated as `False`. | ||
|
||
Parameters | ||
---------- | ||
left : scalar | ||
Left boundary | ||
Left boundary. | ||
right : scalar | ||
Right boundary | ||
Right boundary. | ||
inclusive : bool, default True | ||
Include boundaries. | ||
|
||
Returns | ||
------- | ||
is_between : Series | ||
|
||
Examples | ||
-------- | ||
|
||
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. I think we don't need this blank line. |
||
>>> s = pd.Series([2, 0, 4, 8, np.nan]) | ||
|
||
Boundary values are included by default: | ||
|
||
>>> s.between(1, 4) | ||
0 True | ||
1 False | ||
2 True | ||
3 False | ||
4 False | ||
dtype: bool | ||
|
||
With `inclusive` set to `False` boundary values are excluded: | ||
|
||
>>> s.between(1, 4, inclusive=False) | ||
0 True | ||
1 False | ||
2 False | ||
3 False | ||
4 False | ||
dtype: bool | ||
|
||
`left` and `right` can be any scalar value: | ||
|
||
>>> s = pd.Series(['Alice', 'Bob', 'Carol', 'Eve']) | ||
>>> s.between('Anna', 'Daniel') | ||
0 False | ||
1 True | ||
2 True | ||
3 False | ||
dtype: bool | ||
|
||
See Also | ||
-------- | ||
DataFrame.query : Query the columns of a frame with a boolean | ||
expression. | ||
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. Personally I don't find The ones that I do find related are The |
||
""" | ||
if inclusive: | ||
lmask = self >= left | ||
|
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.
You can leave just
Series
, orSeries of bool
to be more explicit. The returned nameis_between
is not needed.