结合两列给出 nan 输出

时间:2021-04-05 08:46:26

标签: python dataframe nan

我有两个数据框列 y_test 和 x_test 它们具有相同大小的行我的麻烦是在组合这两个数据框时我得到 y_test 列名称标签显示为 nan...详细图像如下所示 enter image description here

我使用的代码是

x_test['label'] = y_test

确实需要更多细节请提及我会提供

1 个答案:

答案 0 :(得分:1)

我通过将 y_test(series) 转换为数组然后进行组合来解决这个难题。

y_test = np.array(y_test)
x_test['label'] = y_test

但我真的很困惑,为什么将系列和数据框结合起来会显示 nan 结果?