0

My data frame looks like -

serial_no                                                       text
   23                                  {'Headers': ['LA-Spanish (Español)[Change]', 
                                      '5790B/5/AF Addendum', 'Secondary menu'], 'Divs': ['', 
                                      'Document(s):5790B/5/AF Addendum (168.88 KB)5790B/5/AF 
                                        AddendumN.º de revisión:00']}

   25                                  {'Headers': ['LA-Spanish (Español)[Change]', 
                                       '700HPPK Service Information', 'Secondary menu'], 
                                      'Paragraphs': [], 'Tables': [], 'Lists': [" 
                                       ['Disclaimer', 'Declaración de privacidad', 'Terms 
                                       of Use', 'Términos y Condiciones']"], 'Divs': ['', 
                                       'Document(s):700HPPK Service Information (3.36 
                                       MB)N.º de revisión:00']}

I want to convert the text column to english language. But that column store in a key value format. My code is given below -

import pandas as pd
from googletrans import Translator
translator = Translator()
df['text2'] = df['text'].apply(lambda x: translator.translate(x, dest='en').text)

I am getting below error -

AttributeError: 'NoneType' object has no attribute 'group'
Nikita Agarwal
  • 343
  • 1
  • 3
  • 13
  • 1
    Seems duplicate to this one : https://stackoverflow.com/questions/52455774/googletrans-stopped-working-with-error-nonetype-object-has-no-attribute-group I'm sorry but it doesn't look like it's solved for googletranslator and that users go for other translating modules. You could also try loading another version for googletranslator. googletrans==3.1.0a0 have been working for most users – Jules Civel Aug 03 '23 at 15:53

0 Answers0