我有47篇新闻文章,我想从中提取情感。它们是JSON格式(日期、标题和文章正文)。我只想用TextBlob获得一个情绪列表。到目前为止,我正在做以下工作:
import json
import pandas
from textblob import TextBlob
appended_data = []
for i in range(1,47):
df0 = pandas.DataFrame([json.loads(l) for l in open('News_%d.json' % i)])
appended_data.append(df0)
appended_data = pandas.concat(appended_data)
doc_set = appended_data.body
docs_TextBlob = TextBlob(doc_set)
for i in docs_TextBlob:
print(docs_TextBlob.sentiment)
很明显,我得到了以下错误:TypeError: The text argument passed to __init__(text) must be a string, not <class 'pandas.core.series.Series'>
你知道如何用情绪度量创建一个列表吗?你知道吗
要在
DataFrame
中使用相关问题 更多 >
编程相关推荐