I want to do an element-wise OR operation on two pandas Series of boolean values. np.nan
s are also included.
I have tried three approaches and realized
first difference : |
is np.bitwise_or
. it explains the difference between #1 and #2.
Second difference : since serie_1.dtype if object
(non homogeneous data), operations are done row by row in the two first cases.
When using vectorize ( #3):
The data type of the output of
vectorized
is determined by calling the function with the first element of the input. This can be avoided by specifying theotypes
argument.
For vectorized operations, you quit the object mode. data are first converted according to first element (bool here, bool(nan)
is True
) and the operations are done after.