[英]How to perform language translation of a column (excel file) to english using Textblob?
My code produced the following error: 我的代码产生了以下错误:
AttributeError: 'function' object has no attribute 'translate'
AttributeError:“函数”对象没有属性“翻译”
More detail: 更多详情:
What is wrong with my code? 我的代码出了什么问题?
import pandas as pd
import numpy as np
from textblob import TextBlob
df_file2= df_file['Repair Details']. apply.translate(from_lang='zh-CN',to ='en')
It looks like you accidentally inserted a space before apply
. 看起来你在
apply
之前不小心插入了一个空格。
Change this: 改变这个:
df_file2= df_file['Repair Details']. apply.translate(from_lang='zh-CN',to ='en')
To this: 对此:
df_file2= df_file['Repair Details'].apply.translate(from_lang='zh-CN',to ='en')
You probably want to use TextBlob
's translate
method. 您可能想要使用
TextBlob
的translate
方法。
Assuming df_file['Repair Details']
have TextBlob objects: 假设
df_file['Repair Details']
具有TextBlob对象:
df_file2= df_file['Repair Details'].apply(lambda x: x.translate(from_lang='zh-CN',to ='en'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.