Python 3.x 这是模棱两可的。具有多个参数的数组使用a.any()或a.all()

Python 3.x 这是模棱两可的。具有多个参数的数组使用a.any()或a.all(),python-3.x,pandas,numpy,dataframe,logical-operators,Python 3.x,Pandas,Numpy,Dataframe,Logical Operators,我想运行以下代码并获取错误信息: 包含多个元素的数组的真值不明确。使用a.any()或a.all() rulebuy=((St_7_3_lastclose_2last))和((St_10_3close_2last))\ 和((St_11_2close_2last)) 打印(规则购买) def st_dir_刷新(ohlc,股票代码): “”“用于检查超趋势反转的函数”“” 全球st_dir 如果ohlc[“st1”][-1]>ohlc[“关闭”][-1]和ohlc[“st1”][-2]ohlc[

我想运行以下代码并获取错误信息: 包含多个元素的数组的真值不明确。使用a.any()或a.all()

rulebuy=((St_7_3_lastclose_2last))和((St_10_3close_2last))\
和((St_11_2close_2last))
打印(规则购买)
def st_dir_刷新(ohlc,股票代码):
“”“用于检查超趋势反转的函数”“”
全球st_dir
如果ohlc[“st1”][-1]>ohlc[“关闭”][-1]和ohlc[“st1”][-2]ohlc[“关闭”][-1]和ohlc[“st2”][-2]ohlc[“关闭”][-1]和ohlc[“st3”][-2]ohlc[“关闭”][-2]:
圣卢西亚[股票代码][0]=“绿色”
如果ohlc[“st2”][-1]ohlc[“关闭”][-2]:
圣卢西亚[股票代码][1]=“绿色”
如果ohlc[“st3”][-1]ohlc[“关闭”][-2]:
圣卢西亚[股票代码][2]=“绿色”

这是否回答了您的问题?
rulebuy =((St_7_3_last < close_last)and (St_7_3_2last > close_2last)) and ((St_10_3 < close_last)and (St_10_3 > close_2last))\
          and ((St_11_2 < close_last)and (St_11_2 > close_2last))
        print(rulebuy)
def st_dir_refresh(ohlc,ticker):
"""function to check for supertrend reversal"""
global st_dir
if ohlc["st1"][-1] > ohlc["close"][-1] and ohlc["st1"][-2] < ohlc["close"][-2]:
    st_dir[ticker][0] = "red"
if ohlc["st2"][-1] > ohlc["close"][-1] and ohlc["st2"][-2] < ohlc["close"][-2]:
    st_dir[ticker][1] = "red"
if ohlc["st3"][-1] > ohlc["close"][-1] and ohlc["st3"][-2] < ohlc["close"][-2]:
    st_dir[ticker][2] = "red"
if ohlc["st1"][-1] < ohlc["close"][-1] and ohlc["st1"][-2] > ohlc["close"][-2]:
    st_dir[ticker][0] = "green"
if ohlc["st2"][-1] < ohlc["close"][-1] and ohlc["st2"][-2] > ohlc["close"][-2]:
    st_dir[ticker][1] = "green"
if ohlc["st3"][-1] < ohlc["close"][-1] and ohlc["st3"][-2] > ohlc["close"][-2]:
    st_dir[ticker][2] = "green"