我想连接2个熊猫数据帧,每个时间序列索引可能会重叠,但也可能与列键可能重叠。沿时间序列索引连接熊猫数据帧而不复制列
例如:
old_close new_close
1TM ABL ... ABL ANG ...
Date Date
2009-06-05 100 564 1990-06-08 120 2533
2009-06-04 102 585 1990-06-05 121 2531
2009-06-03 101 532 1990-06-04 123 2520
2009-06-02 99 540 1990-06-03 122 2519
2009-06-01 99 542 1990-06-02 121 2521
...
我要合并old_close和new_close形成一个新的数据帧,其中包括在两个DataFrames的所有数据,但不包括在这两个指数的所有重复值。
到目前为止,我这样做:
merged_close = pd.concat([old_close, new_close], axis=1)
但这会导致重复列(行时沿轴0)和多指标。
谢谢,但结果数据框仍然包含日期索引上的重复项。这怎么可能? – nswart
我的不好,现在更新了答案 – user1827356