1.当聚合字段是数值型时,用map(str)转化成字符串
df.groupby('Date').Data.transform(lambda x: ",".join(map(str, x.unique())))
2.当聚合字段是字符串类型
df['consol_info']=df.groupby('container_no')['lot_nr'].transform(lambda x:", ".join(x.unique()))
df['Countries_percontainer']=df.groupby('container_no')['Country'].transform(lambda x:", ".join(x.unique()))
标签:join,name,df,transform,报错,unique,groupby From: https://www.cnblogs.com/Jasmine6-Lee/p/16785266.html