Element-wise logical OR in Pandas

858    Asked by ChristianParsons in QA Testing , Asked on Jun 7, 2021

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

I am aware that AND corresponds to & and NOT, ~. But what about OR?

You can use this ‘ | ’ operator for pandas or:

 df[(df < 12 xss=removed>

This will check element-wise if value is less than 12 or equal to 15.

You can also use this np.logical_or function.

df[np.logical_or(df

For multiple conditions use the logical_or.reduce:

df[np.logical_or.reduce([df

Your Answer