I have a pandas dataframe as shown here. There are many more columns in that frame that are not important concerning the task.
id pos value sente
1 a I 21
2 b have 21
3 b a 21
4 a cat 21
5 d ! 21
1 a My 22
2 a cat 22
3 b is 22
4 a cute 22
5 d . 22
I now want to group all rows where sente=sente and join the words in value to form a sentence in a list. So the output should look something like this (a list full of strings seperated by comma) :
["I have a cat!", "My cat is cute."]
I suppose the first step is to use groupby("sente")
fill = (df.groupby("sente").apply(lambda df: df["value"].values)).reset_index().rename(columns={0: "content"})
fill = [word for word in fill["content"]
However doing so I get this output:
print(fill):
[array(['I','have','a','cat','!'],dtype=object), array(['My','cat','is','cute','.'],dtype=object)]
Is there any way to join all words in a sentence without labeling them as a seperate string and to remove the array and dtype part?