【发布时间】:2021-07-08 16:31:07
【问题描述】:
我有以下代码:
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()
创建这个:
我希望只有 2 列,1 列带有情绪,其他带有类别,这应该是特定的情绪,即结果应该是:
| Sentiment | Category |
|---|---|
| abc | positive |
| xmy | negative |
| poi | neutral |
【问题讨论】:
标签: python pandas dataframe nlp sentiment-analysis