I am trying to retrieve the value in A if the value of B is 1. But the below code throws the error "ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()"
A B
0 a1 18
1 b1 25229
2 c2 2
3 d3 12
4 e4 1
Code:
for a,b in df7.iteritems():
if (df7['b'] == 1):
print (df7['a'])
df7.loc[df7.b.eq(1), 'A']?for a,b in df7.iteritems():and then try to reference the columns bydf7['a'],df7['b'], that will return you the entire column.