【发布时间】:2021-10-07 21:29:12
【问题描述】:
申请条件:
我有一个 df,我想根据以下条件填写是/否:
If column1 >= 20 and column2 >= 4 and column3 >= 30 then write Yes else write No
【问题讨论】:
标签: python pandas conditional-statements
申请条件:
我有一个 df,我想根据以下条件填写是/否:
If column1 >= 20 and column2 >= 4 and column3 >= 30 then write Yes else write No
【问题讨论】:
标签: python pandas conditional-statements
可以使用np.where,如下:
df['New_column'] = np.where((df['column1'] >= 20) & (df['column2'] >= 4) & (df['column3'] >= 30), 'Yes', 'No')
【讨论】: