Traceback (most recent call last):
File "<ipython-input-128-7957a219684b>", line 1, in <module>
df.loc[(df['Platform'] == 'A321') and (df['Days'] <= 14), 'Mods Applicable'] = 'CFM56 9th Stage Duct'
File "/Users/nathanielgates/anaconda3/lib/python3.6/site-packages/pandas/core/generic.py", line 1479, in __nonzero__
.format(self.__class__.__name__))
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
尝试使用“&;”而不是“和”:
我可以使用“and”而不是“&;来重现相同的错误:
这是因为将
Series
与值进行比较也会返回Series
。这意味着(df['Platform'] == 'A321')
和(df['Days'] <= 14)
的结果是Series
个true/false
值的Series
,默认情况下它不会解析为单个true或false。所以你不能and
它可以用
&
替换and
。所以它会变成:相关问题 更多 >
编程相关推荐