Error: The truth value of a series is ambiguous. Python & Pandas

后端 未结 1 1971
暗喜
暗喜 2021-01-25 20:36

I\'m trying to identify all the options contracts for MSFT and GOOG that have over 10,000 in volume for the day and to print out the name of the symbol.I am getting the error \"

相关标签:
1条回答
  • 2021-01-25 20:53

    The problem is that the condition (data.Vol > 10000) returns an array of boolean values. NumPy emits that error because it can't know whether you mean to ask "are any of these values > x?", "are all of these values > x?", etc.

    In this case you should use logical indexing to get the rows you're interested in: data[data.Vol > 10000].

    From there, you can get all the relevant symbols: data[data.Vol > 10000].index.get_level_values('Symbol')

    0 讨论(0)
提交回复
热议问题