I'm trying to to find a solution how I could change my pandas dataframe. I have a dataset with news headlines. There are multiple headlines per day. I would like to have the date(day) as rows and each headline gets assigned to a new column per day. In other words I would like to combine all the headline data for each date. Instead of having a separate headline for each day. Some sort of pandas custom aggregator could do the job, but I'm struggling to come up with one.
I was able to group the data by date but now all the headlines per day are in the same column. and not in separate columns. (see picture 2)
df_nyt_all.groupby(['date'], as_index = False).agg({'headline': ','.join})
I have been looking for a solution for a while now but without any luck.
I attached 3 pictures. The first picture shows what my df looked like originally.

The third picture shows an example how I would like the df to look like.


