Simple dataframe in pandas:
A B C
1 1
1 0
0 1
0 0
Say I'd like to populate column C with a 1 if A and B both are 1, else 0. If I try to do something like:
if df['A'] == 1 and df['B'] == 1:
df['C'] = 1
else:
df['C'] = 0
I get something like:
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Which code will be the most efficient and how should it be used?