0

I want to merger all depart_time value with the same location into a list

location    depart_time
022HK   1160
022HK   680
022HK   783.51667
022HK   1268.51667

desired ouput:

location  depart_time
022HK    [680, 783.51667, 1160 1268.51667]
Jack
  • 1,247
  • 1
  • 9
  • 20

1 Answers1

2

You can do df.groupby('location')['depart_time'].apply(list)

Sreeram TP
  • 10,221
  • 6
  • 43
  • 92