Pandas concat: ValueError: Shape of passed values is blah, indices imply blah2

前端 未结 7 1002
梦如初夏
梦如初夏 2020-11-27 16:41

I\'m trying to merge a (Pandas 14.1) dataframe and a series. The series should form a new column, with some NAs (since the index values of the series are a subset of the ind

7条回答
  •  悲&欢浪女
    2020-11-27 17:25

    Aus_lacy's post gave me the idea of trying related methods, of which join does work:

    In [196]:
    
    hl.name = 'hl'
    Out[196]:
    'hl'
    In [199]:
    
    df.join(hl).head(4)
    Out[199]:
    high    low loc_h   loc_l   hl
    2014-01-01 17:00:00 1.376235    1.375945    1.376235    1.375945    1.376090
    2014-01-01 17:01:00 1.376005    1.375775    NaN NaN NaN
    2014-01-01 17:02:00 1.375795    1.375445    NaN 1.375445    1.375445
    2014-01-01 17:03:00 1.375625    1.375515    NaN NaN NaN
    

    Some insight into why concat works on the example but not this data would be nice though!

提交回复
热议问题