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]
You can do df.groupby('location')['depart_time'].apply(list)
df.groupby('location')['depart_time'].apply(list)