Pandas boolean DataFrame selection ambiguity

后端 未结 3 528
一整个雨季
一整个雨季 2021-01-15 22:50

EDIT: Fixed values in tables.

Let\'s say I have a pandas dataframe df:

>>>df
                  a         b         c
        0  0.016367  0.         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-15 23:23

    Since the logical operators are not overridable in python, numpy and pandas override the bitwise operators.

    This means you need to use the bitwise-or operator:

    df[(df > 0.5) | (df < 0)]
    

提交回复
热议问题