我有以下代码:
sentiments = ['He is good', 'He is bad', 'She love her', 'She is fine with it', 'I like going outside', 'Its okay']
positive = [1,0,1,0,1,0]
negative = [0,1,0,0,0,0]
neutral = [0,0,0,1,0,1]
neutral
df = pd.DataFrame({'Sentiments':sentiments, 'Positives':positive, 'Negatives': negative, 'Neutrals':neutral})
df.head()
这就产生了:
我只想有两列,一列是情绪,另一列是类别,这应该是特定情绪,即结果应该是:
情感分类是积极的我的消极的
3条答案
按热度按时间j5fpnvbx1#
尝试
.melt()
:印刷品:
fcg9iug32#
假设只有一列的值为1(即dummies),请尝试:
tktrz96b3#
另一种方式: