【发布时间】:2020-12-23 13:24:41
【问题描述】:
如何在 pandas 中逐行连接列表类型的列?例如见下文-
之前,
1 a [a,b,c]
1 b [a,d]
之后,
1 b [a,b,c,d]
我做了如下的逐列连接,
df['all_poi'] = df['poi_part1'] + df['poi_part2']
电流输出
location_id city all_poi
6265981 Port Severn [Mount St. Louis Moonstone , Horseshoe Valley , Lake Muskoka]
6265981 Port Severn [Mount St. Louis Moonstone , Little Lake Park , Bamboo Spa , Lake Huron]
预期输出
location_id city all_poi
6265981 Port Severn [Mount St. Louis Moonstone , Horseshoe Valley , Lake Muskoka, Little Lake Park , Bamboo Spa , Lake Huron]
检查 all_poi 值它根据 location_id
合并值【问题讨论】: