我有一个数据框,我想为其创建一个名为result的新列,如果“ mean”列的值小于10,则该列应为“ refuse”,否则拒绝列的值应为“ Admitted”
[
答案 0 :(得分:1)
您在这里:
import numpy as np
data['new_col'] = np.where(data['mean'] < 10, 'refuse', 'Admitted')
答案 1 :(得分:0)
data.loc[(data['mean'] < 10), 'result'] = 'Refuse'
data.loc[(data['mean'] >= 10), 'result'] = 'Admitted'