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

时间:2019-03-18 06:33:44

标签: python pandas nlp textblob

我的代码产生以下错误:

  

AttributeError:“函数”对象没有属性“翻译”

更多细节:

error

我的代码有什么问题?

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')

2 个答案:

答案 0 :(得分:0)

您似乎不小心在apply前插入了一个空格。

更改此:

df_file2= df_file['Repair Details']. apply.translate(from_lang='zh-CN',to ='en')

对此:

df_file2= df_file['Repair Details'].apply.translate(from_lang='zh-CN',to ='en')

答案 1 :(得分:0)

您可能想使用Traceback (most recent call last): File "my_python.py", line 14, in <module> from my_tensorflow import run_tensorflow File ".../run_tensorflow.py", line 62, in <module> os.environ["CUDA_VISIBLE_DEVICES"]=str(FLAGS.gpu) File ".../.local/lib/python2.7/site-packages/tensorflow/python/platform/flags.py", line 84, in __getattr__ wrapped(_sys.argv) File ".../.local/lib/python2.7/site-packages/absl/flags/_flagvalues.py", line 633, in __call__ name, value, suggestions=suggestions) absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'n' 的{​​{1}}方法。

假设TextBlob具有TextBlob对象:

translate