The following line causes a ValueError (Pandas 17.1), and I'm trying to understand why.
x = (matchdf['ANPR Matched_x'] == 1)
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I'm trying to use it for following conditional assignment:
matchdf.loc[x, 'FullMatch'] = 1
But I can't get past the previous issue.
I'm sure I've done this kind of thing dozens of times before, and I can't see why it should matter what is in the dataframe, but perhaps it does? or more likely, I'm probably making a silly mistake I just can't see!
Thanks for any help.
EDIT: For more context here's some preceding code:
inpairs = []
for m in inmatchedpairs:
# more code
p = {'Type In': mtype ,'Best In Time': besttime, 'Best G In Time': bestgtime,
'Reg In': reg, 'ANPR Matched': anprmatch, 'ANPR Match Key': anprmatchkey}
inpairs.append(p)
outpairs = []
for m in outmatchedpairs:
# more code
p = {'Type Out': mtype ,'Best Out Time': besttime, 'Best G Out Time': bestgtime,
'Reg Out': reg, 'ANPR Matched': anprmatch, 'ANPR Match Key': anprmatchkey}
outpairs.append(p)
indf = pd.DataFrame(inpairs)
outdf = pd.DataFrame(outpairs)
matchdf = pd.merge(indf, outdf, how='outer', on='ANPR Match Key')
matchdf['FullMatch'] = 0
x = (matchdf['ANPR Matched_x'] == 0)
I get the error on the last line.