mars.dataframe.Series.between#
- Series.between(left, right, inclusive='both')[源代码]#
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.
- 参数
left (scalar or list-like) – Left boundary.
right (scalar or list-like) – Right boundary.
inclusive ({"both", "neither", "left", "right"}) – Include boundaries. Whether to set each bound as closed or open.
- 返回
Series representing whether each element is between left and right (inclusive).
- 返回类型
备注
This function is equivalent to
(left <= ser) & (ser <= right)
示例
>>> import mars.dataframe as md >>> s = md.Series([2, 0, 4, 8, np.nan])
Boundary values are included by default:
>>> s.between(1, 4).execute() 0 True 1 False 2 True 3 False 4 False dtype: bool
With inclusive set to
"neither"
boundary values are excluded:>>> s.between(1, 4, inclusive="neither").execute() 0 True 1 False 2 False 3 False 4 False dtype: bool
left and right can be any scalar value:
>>> s = md.Series(['Alice', 'Bob', 'Carol', 'Eve']) >>> s.between('Anna', 'Daniel').execute() 0 False 1 True 2 True 3 False dtype: bool