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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM