0

I have a dataframe as like below:

df:

enter image description here

The expected output is like below:

enter image description here

I tried like below but doesn't work. I also tried with pivot not working.

df = df.groupby('id').['text'].apply(list)
df = df.reset_index()
pd.DataFrame(df.text.tolist(), index= df.index)

But the output is not expected. It has mixed the languages while grouping. When doing pivot also, I am getting the error "Index contains duplicate entries, cannot reshape". Can someone please help.

  • Please provide a reproducible example DataFrame, images are not. Also with the currently shown example, a `pivot` should work fine (carefully read the duplicate). – mozway Dec 04 '22 at 06:58

0 Answers0