pandas中dataframe拼接了一列是list类型,然后传进去lightgbm模型中进行训练,报错:
ValueError: setting an array element with a sequence.
最终把list类型的列,转成dataframe然后concat到原有的df中就可以了。
确保list的shape没问题,他能够有正常的shape表示,也就是是一个矩阵而不是一个序列即可
train_len_sim=pd.DataFrame(train_data["len_prefix_query1"],index=train_data.index)
test_len_sim=pd.DataFrame(test_data["len_prefix_query1"],index=test_data.index)
train_data=pd.concat([train_data,train_len_sim],axis=1)
test_data=pd.concat([test_data,test_len_sim],axis=1)
。