【问题标题】:Combining Two column give a nan output结合两列给出一个nan输出
【发布时间】:2021-04-05 08:46:26
【问题描述】:

我有两个数据框列 y_test 和 x_test,它们的行大小相同

我使用的代码是

x_test['label'] = y_test

是否需要更多详细信息,请提及我会提供

【问题讨论】:

  • 你为什么不试试 y_test['label']
  • 因为 y_test 是一个系列类型的数据框
  • 如果我尝试它与我所做的会有什么不同
  • print(type(x_test.index))print(type(y_test.index)) 一样吗?
  • No type(x_test) = 和 type(y_test) = 都是各种

标签: python dataframe nan


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 2015-08-13
    • 1970-01-01
    • 2023-04-08
    • 2014-12-02
    • 2010-11-16
    • 1970-01-01
    • 2018-01-26
    • 2022-06-22
    相关资源
    最近更新 更多