简体   繁体   English

如何使用Textblob将列(Excel文件)的语言翻译为英语?

[英]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. 您可能想要使用TextBlobtranslate方法。

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.

相关问题 Python:使用 TextBlob NLTK 读取文本文件并检测语言 - Python: Using TextBlob NLTK to read a text file and detect the language 如何使用BeautifulSoup写入非英语文件 - How to write to file non-English language using BeautifulSoup 在 excel 文件数据上使用 python textblob 进行情绪分析 - Sentiment analysis using python textblob on a excel file data 使用textblob拼写在意大利语的文本 - Spelling text in italian language using textblob 如何使用TextBlob创建带双引号的JSON文件 - How to create JSON file with double quotes using TextBlob 使用 TextBlob 执行情感分析的缺点和潜在问题是什么? 他们怎么能解决? - What are the cons and potenzial problems of using TextBlob to perform sentiment analysis? How could they be solved? 在 TextBlob 中使用翻译功能时出现“HTTPError:HTTP 错误 404:未找到” - "HTTPError: HTTP Error 404: Not Found" while using translation function in TextBlob TextBlob 翻译有限制吗? - Is there a limit on TextBlob translation? 如何使用 Python 从 CSV 文件的列中删除英文单词 - How to remove English Words from a column in a CSV file using Python 如何使用 pybabel 获得特定语言的翻译 - How to get a specific language translation using pybabel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM