pandas query

have the precedence of 优先于

按位操作符 bitwise operators

The query() method uses a slightly modified Python syntax by default. For example, the & and | (bitwise) operators have the precedence of their boolean cousins, and and or. This is syntactically valid Python, however the semantics are different.

& and | (bitwise) operators 按位操作 优先于 and and or 布尔操作

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.query.html?highlight=query#pandas.DataFrame.query

解答:

https://blog.csdn.net/lanchunhui/article/details/50672889

  • boolean 算子(and/or)主要用于布尔值(True/False),而位操作子(bitwise operator,&/|)通常用于整型之间