AttributeError:在Python中使用eval函数时,“ UnaryOp”对象没有属性“ evaluate”

问题描述

for test_ind,case_data in test_df.iterrows():
      case_data = case_data.to_frame().T
      rule = "Ask_before>-0.4843681 & 0.5255821<=BidVol_before<=0.07581073 & Volume>0.1107559"
      print(case_data,"case_data")
      if case_data.eval(rule).all() == True:
          print("TRUE")

此处,当规则包含负值时,将出现此错误。您能帮我解决这个问题吗?我需要检查此规则是否适用于数据框中的实例。 Ask_before,BidVol_before是数据帧test_df的列。您能帮我解决这个问题吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)