between()函数

1 between函数返回一个布尔量,即如果在该范围内,返回True,否则返回False.

在dataframe中常可用来通过选择某一列元素的范围来选择另一列.

between()函数
import pandas as pd
import numpy as np

df = pd.DataFrame(np.arange(24).reshape(6,4), columns=list('ABCD'))
print(df)
a = df['A'].between(3,13)
print(df[a]['D'])
#     A   B   C   D
# 0   0   1   2   3
# 1   4   5   6   7
# 2   8   9  10  11
# 3  12  13  14  15
# 4  16  17  18  19
# 5  20  21  22  23
# 1     7
# 2    11
# 3    15
# Name: D, dtype: int64
View Code

 

上一篇:SLAM算法安装运行介绍


下一篇:线段树 I - Transformation