【发布时间】:2018-09-04 18:17:37
【问题描述】:
我正在做情绪分析项目。我得到了结果。我数了数正数、中性数和负数。
这是代码
ltweet.groupby(['sentiment_type'])['sentiment_neutral'].count()
# ltweet= the name of object
# sentiment_type= column
#sentiment_neutral= column
这是输出
Out[105]:
sentiment_type
NEGATIVE 280
NEUTRAL 1308
POSITIVE 1193
Name: sentiment_neutral, dtype: int64
我只想显示“积极”(不是消极和中性)
我尝试了其他代码,但仍然出现错误。谁能帮我这个?
【问题讨论】:
-
s = ltweet.groupby(['sentiment_type'])['sentiment_neutral'].count(),然后是print (s['POSITIVE']) -
你想要正面记录吗?
-
@MAttR ,我想只显示'POSITIVE 1193'
标签: python pandas numpy count pandas-groupby