【问题标题】:Add data to Dataframe with pandas使用 pandas 将数据添加到 Dataframe
【发布时间】:2019-08-12 20:11:09
【问题描述】:

我想将模拟模型的结果添加到现有数据帧中特定位置的数据帧。

基于线性回归的数据框和模型,我正在计算一个值。该值必须添加到用于线性回归的输入数据框中。我正在使用熊猫插入函数,它会带来以下错误:

enter image description here

【问题讨论】:

  • 看起来y_heute_10 有两个维度(即嵌套括号),但只包含一个值。试试df.insert(2, 'Stunde_10', y_heute_10[0])

标签: python pandas dataframe insert


【解决方案1】:

非常感谢您的帮助。它适用于:

X_heute_10 = df2.insert(4, 'Stunde_10', y_heute_10[0,0])

【讨论】:

    猜你喜欢
    • 2013-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-13
    • 1970-01-01
    相关资源
    最近更新 更多