Keith Keith - 24 days ago 4x
Python Question

Element-wise logical OR in Pandas

I would like the element-wise logical OR operator. I know "or" itself is not what I am looking for.

For AND I want to use & as explained here. For NOT I want to use np.invert() as explained here. So what is the equivalent for OR?


The corresponding operator is |:

 df[(df < 3) | (df == 5)]

would elementwise check if value is less than 3 or equal to 5.