我有一个主数据帧,有6行。 我想将其他几个数据帧中的值添加到pl列中,但是其他数据帧将具有行的子集。 我不想在缺少的行中创建NaN值。 以下是主数据帧:
pl
Date
2010-01-27 7.0
2010-01-28 7.0
2010-01-29 7.0
2010-02-01 7.0
2010-02-02 7.0
2010-02-03 7.0
下面是我要添加到主服务器的日期帧
edge
Date
2010-01-28 6.747998
2010-01-29 4.497736
2010-02-01 6.977076
2010-02-02 10.016789
下面是我的代码:
df_master.pl += df_y.edge
以下是(不想要的)结果:
pl
Date
2010-01-27 NaN
2010-01-28 13.747998
2010-01-29 11.497736
2010-02-01 13.977076
2010-02-02 17.016789
2010-02-03 NaN
我要拿回我的七分!
使用add
检查
df_master.pl = df_master.pl.add(df_y.edge, fill_value=0)