Reputation: 53
result=pd.Series([True,False,False]) | pd.Series([False,True,True],index=[1,2,3])
result
out:
0 True
1 False
2 True
3 False
dtype: bool
how does the Series do logical or? why the result[3] is True?
in:
print(pd.Series([np.nan]) | pd.Series([True]))
print('----')
print(pd.Series([True]) | pd.Series([np.nan]))
out:
0 False
dtype: bool
----------
0 True
dtype: bool
could someone help to explain the difference between two times logical or?
Upvotes: 3
Views: 167
Reputation: 9758
First of all, these are two questions.
For the first question:
Your problem is that you're setting the index of the second series starting from 1
rather than 0
(the default).
So, while the first Series has indexes [0, 1, 2]
, the second one has [1, 2, 3]
.
For the second question:
Please refer to this answer here in SO: https://stackoverflow.com/a/37132854/677022
Upvotes: 2