Here is an example:
df1:
X Y Z
1 a cat
1 a dog
2 b hi
2 b hello
2 b hey
The final df should look like this.
df2:
X Y Z
1 a [cat, dog]
2 b [hi, hello, hey]
I'm really stuck and I'm having trouble even approaching this. Any help would be much appreciated.