mars.dataframe.Series.between#
- Series.between(left, right, inclusive='both')[来源]#
返回一个布尔系列,等价于左侧 <= 系列 <= 右侧。这个函数返回一个布尔向量,包含 True,在对应的系列元素位于边界值 left 和 right 之间的地方。NA 值被视为 False。
- Parameters
left (标量 或 类似列表) – 左边界。
right (标量 或 类列表) – 右边界。
inclusive ({"both", "neither", "left", "right"}) – 包含边界。是否将每个边界设置为闭合或开放。
- Returns
表示每个元素是否在左边和右边之间(包含)。
- Return type
备注
此函数等价于
(left <= ser) & (ser <= right)示例
>>> import mars.dataframe as md >>> s = md.Series([2, 0, 4, 8, np.nan])
边界值默认包含:
>>> s.between(1, 4).execute() 0 True 1 False 2 True 3 False 4 False dtype: bool
当 inclusive 设置为
"neither"时,边界值被排除:>>> s.between(1, 4, inclusive="neither").execute() 0 True 1 False 2 False 3 False 4 False dtype: bool
left 和 right 可以是任何标量值:
>>> s = md.Series(['Alice', 'Bob', 'Carol', 'Eve']) >>> s.between('Anna', 'Daniel').execute() 0 False 1 True 2 True 3 False dtype: bool