pandas 分组 合并多个元素

res.groupby(['customer_id'])['project_name'].apply(lambda x:', '.join(x)).reset_index()

x.groupby(['sa'])['daList'].apply(lambda x:np.concatenate(list(x))).reset_index()
Out[340]: 
   sa            daList
0   2            [2, 3]
1   3         [4, 5, 9]
2   5  [44, 55, 23, 45]
3   7              [66]
————————————————
原文链接:https://blog.csdn.net/u011012422/article/details/82773618

 

posted @ 2020-02-06 18:22  cup_leo  阅读(1161)  评论(0编辑  收藏  举报