Series.between(left, right, inclusive=True)
[source]
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. right : scalar Right boundary. inclusive : bool, default True Include boundaries. |
---|---|
Returns: |
Series Each element will be a boolean. |
See also
pandas.Series.gt
pandas.Series.lt
This function is equivalent to (left <= ser) & (ser <= right)
>>> 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
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
http://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.Series.between.html