0

I have a simple dataframe and I'm trying to perform local "groupby" operations in this dataframe using Python. (The goal here is to detect each changement of value in the column "style"). In other words , i have a dataframe like that :

style, text
T1, John
T1, lionel
T1, michael
T1, lindsey
T3, patrick
T3, jim
T4, heather
T4, lola
T4, steve
T2, paul
T2, dave
T1, michel
T1, anouch
T4, zinedine
T4, brian
..,    ..

and I want to obtain this resulting dataframe :

style, text
T1, [John, lionel, michael, Lindsey]
T3, [patrick, jim]
T4, [heather, lola, steve]
T2, [paul, dave]
T1, [michel, anouch]
T4, [zinedine, brian]
.. ,  ..

I know this probably possible with "groupby" but I 'm not able to achieve this particular operation (it is not a classic "groupby")...

Thanks you for your help

dkk
  • 141
  • 1
  • 11

0 Answers0