I have a data frame named train_df:
| text | label |
|---|---|
| I'm loving Instagram | |
| I'm loving Linkedin | |
| I'm loving Facebook | |
| I'm loving Twitter |
I am trying to put the text into a list and put the lists into a dictionary with the keys being the label e.g
my_dict = {'Instagram' : [I'm loving Instagram], 'Linkedin': [I'm loving Linkedin]...}
At the moment, the code I've written to get this done is:
my_dict = dict()
for i in train_df.label.unique():
my_dict[i] = " ".join(train_df[train_df["label"] == "@i"]["text"].tolist())
I get a dictionary as described above but the values are empty. I'm not sure what I'm doing wrong and any help is really appreciated. Thank you so much!!!