我想用另一列的值填充数据框,我使用条件来填充值。我想要填写的条件是当列“Essentieel_Optioneel”中的值 ==“essentieel”时,需要用 perc_essentieel_skill 填充值。当值为“optioneel”时也是如此。
conditions = [
(df1['Essentieel_Optioneel'] <= 'essentieel'),
(df1['Essentieel_Optioneel'] <= 'optioneel')
]
values = df1[['perc_essentieel_skill','perc_essentieel_skill']]
df1['vector'] = np.select(conditions, values)
df1
811 'list of cases must be same length as list of conditions')
813 # Now that the dtype is known, handle the deprecated select([], []) case
814 if len(condlist) == 0:
ValueError: list of cases must be same length as list of conditions
我觉得我的数据框太长了,我有一个 19913 * 12 列的框。
我感觉我必须使用 for 循环。