I have a dataframe of this shape:
anger fear joy love sadness surprise thankfulness disgust guilt
0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
1 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
2 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
3 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
4 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
You can notice how the emotions labels ['anger', 'fear', 'joy', 'love', 'sadness', 'surprise', 'thankfulness', 'disgust', 'guilt']
are formatted in a column-based way, what I want to do is, instead of multiple columns, we add another column (emotion) such that it stores the emotion labels based on a predefined dictionary:
{0: 'anger',
1: 'fear',
2: 'joy',
3: 'love',
4: 'sadness',
5: 'surprise',
6: 'thankfulness',
7: 'disgust',
8: 'guilt'}
Example output (different dataframe):
Emotion Text
0 joy During the period of falling in love, each tim...
1 fear When I was involved in a traffic accident.
2 anger When I was driving home after several days of...
3 sadness When I lost the person who meant the most to me.
4 disgust The time I knocked a deer down - the sight of ...
I'm looking for a more of a Pandas-way to do this