简体   繁体   English

使用 googletrans 翻译 Pandas df,AttributeError 错误

[英]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为避免错误,请参考此答案

Source 1 来源 1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 googletrans 在 Python 中翻译 Pandas 系列? - How to translate a Pandas Series in Python using googletrans? googletrans 字典翻译错误 - googletrans error with dictionary translate 使用 googletrans python 包进行波斯语的 AttributeError 错误 - AttributeError error using googletrans python package for farsi language 在 python translate() 中使用 googletrans api 时出错,缺少 1 个必需的位置参数:'self' - Error using googletrans api in python translate() missing 1 required positional argument: 'self' 在 Pandas df 上运行 lower_case.translate 和 string.punctuation 时出现 AttributeError - AttributeError running lower_case.translate & string.punctuation on Pandas df Googletrans API 属性错误 - Googletrans API AttributeError 尝试使用 googletrans 翻译内容时出现错误 - I get an error when I try to translate something with googletrans AttributeError:“NoneType”对象在使用 googletrans 库时没有属性“组” - AttributeError: 'NoneType' object has no attribute 'group' while using googletrans library 我正在使用 python3,我想翻译一些文本,所以我使用了“googletrans”package,但我收到了一些错误 - I am using python3 and I want to translate some text, So I used “googletrans” package, but I am getting some error json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 有时在 Python 中使用 googletrans 和 Pandas 会发生错误 - json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) error occurs sometimes using googletrans and Pandas in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM