Pandas 添加两列具有不同日期的时间序列数据帧
我希望添加两列不同的日期范围Pandas 添加两列具有不同日期的时间序列数据帧,pandas,dataframe,addition,Pandas,Dataframe,Addition,我希望添加两列不同的日期范围 column 1 = values with date index 2 Nov to 23 Nov column 2 = values with date index 27 Oct to 17 Nov Resultant = addition of values in column 1 and column 2 of 27 Oct to 23 Nov 样本图片附上 dataframeA的第1列包含11月2日至11月23日的数据;每个元素 它的值为100 数据
column 1 = values with date index 2 Nov to 23 Nov
column 2 = values with date index 27 Oct to 17 Nov
Resultant = addition of values in column 1 and column 2 of 27 Oct to 23 Nov
样本图片附上
Date Value
0 2-11-2020 21.0
1 3-11-2020 4.0
2 4-11-2020 6.0
Date Value
0 3-11-2020 2.0
1 4-11-2020 2.0
2 5-11-2020 7.0
Date Value
0 2-11-2020 21.0
1 3-11-2020 6.0
2 4-11-2020 8.0
3 5-11-2020 7.0
df2:
Date Value
0 2-11-2020 21.0
1 3-11-2020 4.0
2 4-11-2020 6.0
Date Value
0 3-11-2020 2.0
1 4-11-2020 2.0
2 5-11-2020 7.0
Date Value
0 2-11-2020 21.0
1 3-11-2020 6.0
2 4-11-2020 8.0
3 5-11-2020 7.0
应该是:
df = df1.set_index('Date').add(df2.set_index('Date'), fill_value=0).reset_index()
df:
Date Value
0 2-11-2020 21.0
1 3-11-2020 4.0
2 4-11-2020 6.0
Date Value
0 3-11-2020 2.0
1 4-11-2020 2.0
2 5-11-2020 7.0
Date Value
0 2-11-2020 21.0
1 3-11-2020 6.0
2 4-11-2020 8.0
3 5-11-2020 7.0
请提供一个可复制的示例,通过发布带有预期输出的示例输入数据框。