data=pd.DataFrame({'v_id':['d1','d2'],
'pred_class':['cat,dog','other_label,fish'],
'pred':[[0.72,0.65],[0.11,0.23]],
'id_part':['d',5],})
In [240]:
data
Out[240]:
In [247]:
animal=data['pred_class'].str.split(',',expand=True).stack().reset_index(level=1,drop=True).rename('animal')
In [256]:
data['pred_class'].values
Out[256]:
In [261]:
animal
Out[261]:
In [272]:
pred=np.concatenate(data['pred'].values) #concatenate()函数的用法
pred1=pd.DataFrame({'pred1':pred})
In [277]:
pred1
Out[277]: