0

Estoy intentando traducir una columna de un dataframe que contiene texto en español a inglés para luego aplicar librerías para análisis sentimental, pero no estoy pudiendo, siempre me salta el siguiente error:

AttributeError: 'NoneType' object has no attribute 'group'

Mi código:

from googletrans import Translator

translator = Translator() 

translated = translator.translate(df_todos1['Titular'], src='es', dest='en')

print(translated)

En caso de ser necesario puedo agregar información como la estructura del data frame.

Saludos y gracias.

1
  • Hola Agustin! Sí sería conveniente que creases un DataFrame de ejemplo en código de ejemplo, así lo podremos copiar y será más fácil reproducir tu problema y ayudarte! el 10 feb. 2021 a las 8:18

1 respuesta 1

0

Prueba con google_trans_new: https://github.com/lushan88a/google_trans_new

Instalación:

pip install google_trans_new

Código Python:

from google_trans_new import google_translator
translator = google_translator()  
translated = translator.translate(df_todos1['Titular'], lang_src='es', lang_tgt='en')  
print(translated)
3
  • Hola!, gracias por tu respuesta, me fue muy util. El problema que tengo ahora es que la lista translated son las traducciones de los titulos pero en un único elemento, es decir, me devuelve una lista con un solo elemento el cual es todas las traducciones. Quisiera obtener las traducciones pero cada una siendo un elemento distinto. Sabes como podría hacerlo con google_trans_new? Estoy intentando pero no he podido. Muchas gracias! el 15 feb. 2021 a las 19:21
  • ¿Podrías escribir la lista que te devuelve? el 16 feb. 2021 a las 0:55
  • 0 Lacalle Pou is meeting with the president of ... 1 Recyclables: the failure of Montevideo and why ... 2 Prince Philip, husband of the re ... 3 Vaccines against covid-19 will arrive in March and ... 4 What is emotional salary and why is it vital ... ... 3315 This week the brutal BMW M5 CS stands out, with 6 ... 3316 25 years of the Portal: when “the boys of M ... 3317 Montevideo Portal turns 25 and celebrates it ... 3318 Editorial | 25 and counting 3319 The challenge of celebrating 25 years of ... Name: Headline, Length: 3320, dtype: object el 17 feb. 2021 a las 17:56

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.