I have a pandas dataframe:
Overall | Language |
---|---|
Hello | en |
Hola | es |
I would like to create another column - Overall Correct - where the text is translated to english. Thus, the condition is that if the language is equal to "en", then do not translate. Else, translate from Spanish to English.
Any suggestion on how to do that? I am trying to use this code with no luck:
from googletrans import Translator
translator = Translator()
df['Overall Correct'] = [df['Overall'] if x == 'en' else translator.translate(df['Overall'], src='es', dest='en') for x in df['Language']]