天池大赛查漏补缺:TypeError: ufunc 'add' did not contain a loop with signature matching types

为了dateframe两列合并在一起,中间以","分开

天池大赛查漏补缺:TypeError: ufunc 'add' did not contain a loop with signature matching types_第1张图片

train['ccount']=train['buyer_admin_id']+','+train['item_id']
出现TypeError: ufunc 'add' did not contain a loop with signature matching types

一直以为是','的问题 因为train['ccount']=train['buyer_admin_id']+train['item_id']可单独执行

猜测 ['buyer_admin_id'] ['item_id']存储为int变量,增加强制转换

a=' '
train['buyer_admin_id']=train['buyer_admin_id'].astype(str)
train['item_id']=train['item_id'].astype(str)
train['ccount']=train['buyer_admin_id']+a+train['item_id']

天池大赛查漏补缺:TypeError: ufunc 'add' did not contain a loop with signature matching types_第2张图片

达到目的

你可能感兴趣的:(Python查漏补缺,天池竞赛查漏补缺)