如何解决AttributeError:“系列”对象没有属性“文本”错误?

时间:2019-04-11 11:23:20

标签: python nlp nltk

我正在尝试使用以下代码将句子拆分成单词:

for index, row in train.iterrows():
    words_filtered = [e.lower() for e in row.text.split() if len(e) >= 3]
    words_without_stopwords = [word for word in words_filtered if not word in stopwords_set]
    reviews.append((words_without_stopwords, row.Sentiment))

但是我得到了错误:

Traceback (most recent call last):
  File "<pyshell#44>", line 2, in <module>
    words_filtered = [e.lower() for e in row.text.split() if len(e) >= 3]
  File "C:\Python27\lib\site-packages\pandas\core\generic.py", line 5067, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'text'

无法解决该问题

0 个答案:

没有答案