【发布时间】:2021-04-05 09:20:55
【问题描述】:
How to iterate the list and get the sentiments through pandas dataframe column?
我有一个只有一列的数据框,并且该列中只有 cmets。
data.head()
输出:
Review
0 If you've ever been to Disneyland anywhere you...
1 Its been a while since d last time we visit HK...
2 Thanks God it wasn t too hot or too humid wh...
3 HK Disneyland is a great compact park. Unfortu...
4 the location is not in the city, took around 1...
我正在使用拥抱脸情绪分类器,例如返回评论的情绪
classifier("My name is mark")
输出是:
[{'label': 'POSITIVE', 'score': 0.9953688383102417}]
只获取标签:
basic_sentiment = [i['label'] for i in value if 'label' in i]
basic_sentiment
输出是:
['POSITIVE']
如何在分类器的dataframe中运行所有给定的cmets并返回输出?
sent = []
for i in text[:]:
sentiment = classifier(i)
sent.append(sentiment)
我试过上面的代码,但是它返回错误
【问题讨论】:
标签: python pandas list dataframe sentiment-analysis