I have the following dataframe:
df = pd.DataFrame([
[123, 'abc', '121'],
[124, 'abc', '121'],
[456, 'def', '121'],
[123, 'abc', '122'],
[123, 'abc', '122'],
[456, 'def', '145'],
[456, 'def', '145'],
[456, 'def', '146'],
], columns=['userid', 'name', 'dt'])
I have grouped it according to the date:
df2 = df.groupby('dt').apply(lambda df: df.reset_index(drop=True))
Now, the dataframe looks like this:

Now, I want to pivot the above such that they are in this format:
userid name_1, name_2, ..., name_k for each group such that the end df looks something like this:
userid name
123 abc
124 abc
456 def
123 abc, abc