我已经有一个名为"bad_outcomes"的集合和一个数据框,其中一个列名为"Outcome"。
使用"Outcome",我想创建一个列表,如果对应行的Outcome在bad_outcomes集合中,则元素为0; 否则为1。
然后我想将它分配给变量'landing_class'。
我已经写了这个:
landing_class = []
if df['Outcome'].isin(set(bad_outcomes)):
landing_class.append(0)
else:
landing_class.append(1)
它没有工作。我遇到了一个错误。
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().