0
我想创建一个if/then语句,通过我在熊猫表中的每一行,但我无法弄清楚如何去做。熊猫如果语句迭代遍历行
entry_price = df['0VWAP']
low_price = df['0L']
df["stopped"] = low_price < .95*entry_price
for row in df:
if df['stopped'].bool == True:
print 'Stopped out'
else:
print 'Open'
当我运行这段代码时,它会打印所有内容,当它应该是两者的混合时。
你遍历'row',但没有检查它在所有的你的'if'语句。尝试像'if row.stopped:'。 –