首页 > 其他分享 >transform映射失败-报错 unique is not a valid function name for transform(name)

transform映射失败-报错 unique is not a valid function name for transform(name)

时间:2022-10-12 17:23:20浏览次数:64  
标签:join name df transform 报错 unique groupby

 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

相关文章