Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python AWS翻译-Excel_Python_Python 3.x_Amazon Web Services_Boto3_Botocore - Fatal编程技术网

Python AWS翻译-Excel

Python AWS翻译-Excel,python,python-3.x,amazon-web-services,boto3,botocore,Python,Python 3.x,Amazon Web Services,Boto3,Botocore,我有一个包含多列的excel文件。里面的数据是英文的,我想把它们全部翻译成法语,然后得到新的excel 问题是translate_txt不接受数据帧,有没有办法解决这个问题 import boto3 import pandas as pd translate = boto3.client(service_name='translate', region_name='us-east-1', use_ssl=True) df = pd.read_excel('data.xlsx') result

我有一个包含多列的excel文件。里面的数据是英文的,我想把它们全部翻译成法语,然后得到新的excel

问题是translate_txt不接受数据帧,有没有办法解决这个问题

import boto3
import pandas as pd

translate = boto3.client(service_name='translate', region_name='us-east-1', use_ssl=True)

df = pd.read_excel('data.xlsx')
result = translate.translate_text(Text=df,SourceLanguageCode="en", TargetLanguageCode="fr")

我要感谢@JonClements为解决这个问题提供的巨大帮助

@JonClements提供的解决方案有效- df.applymaplambda c:translate.translate_textText=c,SourceLanguageCode='en',TargetLanguageCode='fr'


我面临的问题主要是有INT的专栏,而且applymap工作得很有魅力。

df.applytranslate.translate\u text、SourceLanguageCode='en',TargetLanguageCode='fr'对你有用吗?我想不行,但让我再次尝试一下。如果不是,您会得到什么错误/结果?`File/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py,第312行,在_api_调用%s中只接受关键字参数。%py_操作\u名称类型错误:translate_text仅接受关键字参数。`df.applymaplambda c:translate.translate_textText=c,SourceLanguageCode='en',TargetLanguageCode='fr'可能吗?