您可以
join在以下时间申请专栏
groupby:
df.groupby('index')['words'].apply(','.join)
例:
In [326]:df = pd.Dataframe({'id':['a','a','b','c','c'], 'words':['asd','rtr','s','rrtttt','dsfd']})dfOut[326]: id words0 a asd1 a rtr2 b s3 c rrtttt4 c dsfdIn [327]:df.groupby('id')['words'].apply(','.join)Out[327]:ida asd,rtrb sc rrtttt,dsfdName: words, dtype: object
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)