Okay, I edited this question with a new example.
I can't fill my new column df['Colour']
in my dataframe.
#I used an example of one of the answers:
d = {"symbol":["Heart", "Heart", "Diamond", "Spade"], "symbol2":["Heart","Diamond", "Spade", "Spade"]}`
df_s = pd.DataFrame(d)
df_s['color'] = df_s['symbol'].map(lambda x: 'Correct' if x == df_s['symbol2'] else 'Wrong')
With this code, I want to create a new column called 'Colour' and fill the blanks with the values with 'Correct'
or 'Wrong'
.
But I only get the error:
Error: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
What did I do wrong?
Edit: The Error stays still the same.