I have a pandas dataframe like this,
dd = pd.DataFrame(
{'name': ['abc','bcd','abc'],
'seconds': [75,77,90],
})
I need to combine the seconds column into a single list for rows with same name.
I am able to do this using for loop,
names= list(set(dd['name']))
counter=[]
for a in names:
counter.append(list(dd[dd['name'] == a]['seconds']))
end
seconds_list = pd.DataFrame(
{'name': names,
'seconds': counter,
})
Output:
But this takes a lot of time on a big dataframe. Any simple way to achieve this without a for loop?
Thanks!

