In the code:
df = pd.DataFrame([[False, 0], [False, 1], [False, 2], [False, 2], [False, 3], [False, 4], [False, 5]],
columns=['cond1', 'cond2'])
df['test'] = (~df['cond1']) & (df['cond2'])
I'm expecting to get in the test
column the value True
in all rows except the first, as the truthy value of any number but 0 is True
. However, I'm getting False
where the value in cond2
is 2 or 4. Why?
The output of the above code:
cond1 cond2 test
0 False 0 False
1 False 1 True
2 False 2 False
3 False 2 False
4 False 3 True
5 False 4 False
6 False 5 True