I have a data frame with comments and their labels.
| Comments | Label |
|---|---|
| I love my Teammates | Positive |
| We need higher pay | Suggestions |
| I hate my boss | Negative |
I would like to get an output like
| Word | count | Positive | Negative | Suggestions |
|---|---|---|---|---|
| I | 2 | 1 | 1 | 0 |
| my | 2 | 1 | 1 | 0 |
| Teammates | 1 | 1 | 0 | 0 |
| love | 1 | 1 | 0 | 0 |
| We | 1 | 0 | 0 | 1 |
| need | 1 | 0 | 0 | 1 |
| higher | 1 | 0 | 0 | 1 |
| pay | 1 | 0 | 0 | 1 |
| hate | 1 | 0 | 1 | 0 |
| boss | 1 | 0 | 1 | 0 |
I was able to get the word count by using
df.Comments.str.split(expand=True).stack().value_counts()
But I am not able to get the label counts. Any help will be appreciated!