I am performing boolean operation on two Series. I was expecting the boolean operation to automatically do the operation corresponding to the same index. But instead it just does it by order. Is this the expected behavior or there is some different way of doing this?
b Out: AEIS False AAPL True ACFN False Name: OldPosition, dtype: bool a Out: AAPL True ACFN False AEIS True dtype: bool a&b Out: AAPL False ACFN False AEIS False dtype: bool
This seems like a bug to me:
In : a = pd.Series([True, False, True], list('bca')) In : b = pd.Series([False, True, False], list('abc')) In : a & b Out: b False c False a False dtype: bool
One way to workaround is to reindex using the same index:
In : index = a.index | b.index In : a.reindex(index) & b.reindex(index) Out: a False b True c False dtype: bool