New to pandas, so please bear with me.
I have a text processing function I'd like to run on a column in my datafame conditional on the value in another column. I've seen
Depending on whether something is flagged, I want to run a translation function on it.
account article ... translation flag
0 123 text ... 1
1 123 text ... 0
2 123 text ... 1
I tried:
df['translation'] = df[['flag', 'text']].apply(lambda x: translate(['article']) if ['flag'] == 1 else None)
and get this in return:
ValueError: ('The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().', 'occurred at index flag')
Any help or guidance would be appreciated.