标签: python pandas
import pandas as pd import numpy as np df = pd.DataFrame([np.random.rand(100),100*[0.1],100*[0.3]]).T df.columns = ["value","lower","upper"] df.head()
如何创建新列,表明value介于lower和upper之间?
value
lower
upper
答案 0 :(得分:3)
您可以将between用于此目的。
between
df['new_col'] = df['value'].between(df['lower'], df['upper'])