熊猫新手,请耐心等待。
我有一个文本处理函数,我想在我的 datafame 中的一列上运行,条件是另一列中的值。我见过
根据是否标记某些内容,我想对其运行翻译功能。
account article ... translation flag
0 123 text ... 1
1 123 text ... 0
2 123 text ... 1
Run Code Online (Sandbox Code Playgroud)
我试过:
df['translation'] = df[['flag', 'text']].apply(lambda x: translate(['article']) if ['flag'] == 1 else None)
并得到这个回报:
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')
Run Code Online (Sandbox Code Playgroud)
任何帮助或指导将不胜感激。