0

Let say I have this dataframe.

+-----------------+-----------+
|     COMMENT     | SENTIMENT |
+-----------------+-----------+
| Good app        | Positive  |
| Bad app         | Negative  |
| Useless feature | Negative  |
| I like this app | Positive  |
+-----------------+-----------+

I want to split it based on the SENTIMENT column. Like this below.

+-----------------+-----------+
|     COMMENT     | SENTIMENT |
+-----------------+-----------+
| Good app        | Positive  |
| I like this app | Positive  |
+-----------------+-----------+


+-----------------+-----------+
|     COMMENT     | SENTIMENT |
+-----------------+-----------+
| Bad app         | Negative  |
| Useless feature | Negative  |
+-----------------+-----------+

Anyone knows the solution in Python (Jupyter) for that case? Your help will help my thesis project. Thank you :D

1 Answers1

1

Simply you can use df1 = df[df["SENTIMENT"]=="Positive"]

Then df1 will have:

enter image description here

df2 = df[df["SENTIMENT"]=="Negative"]

Then df2 will have:

enter image description here

deadshot
  • 8,881
  • 4
  • 20
  • 39
Aminul
  • 1,427
  • 2
  • 8
  • 16