Reputation: 1122
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()
How can I create a new column which indicates that value
is between lower
and upper
?
Upvotes: 0
Views: 507
Reputation: 29719
You can use between
for this purpose.
df['new_col'] = df['value'].between(df['lower'], df['upper'])
Upvotes: 2