3
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?

Kevin liu
  • 53
  • 4

1 Answers1

2

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

Nicolás Ozimica
  • 9,481
  • 5
  • 38
  • 51