[英]Translate a Pandas df using googletrans, AttributeError error
I am trying to translate words from a Pandas dataframe column and get error in googletrans.Translator() class.我正在尝试翻译 Pandas dataframe 列中的单词,并在 googletrans.Translator() class 中出现错误。 It works normal with single words or phrases.
它适用于单个单词或短语。 Can it be environmental issue?
会不会是环境问题?
Any help or suggestions much appreciated非常感谢任何帮助或建议
import pandas as pd
from googletrans import Translator
translator = Translator()
df = pd.DataFrame({'Spanish':['piso','cama']})
df['English'] = df['Spanish'].apply(translator.translate, src='es', dest='en').apply(getattr, args=('text',))
Output: Output:
AttributeError: 'Translator' object has no attribute 'raise_Exception'
Hi this error occured because there is an exception occurred in the runtime.您好,发生此错误是因为运行时发生异常。 To see the error insert this below code
要查看错误,请在下面插入代码
python translator.raise_Exception = True
If you get the error as below python translator.raise_Exception = True
如果您收到如下错误
Exception: Unexpected status code "429" from ['translate.google.com']
which means Too many requests.这意味着太多的请求。 Hope you would not get this error.
希望您不会收到此错误。 If so you have to upgrade you account.
如果是这样,您必须升级您的帐户。 To avoid the error please refer this answer
为避免错误,请参考此答案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.