条件合并数据框

时间:2018-05-28 15:45:17

标签: python pandas

有两个数据帧:

DataFrames

如何将df1与df2合并,以便我们得到以下结果  在X:

Ticker   Type   Date
======   ====   ====
OEX      Index  2018-06-01
XEO      Index  2018-06-01
SPX      Index  2018-06-01
SPX      Index  2018-06-08
SPX      Index  2018-06-22

......等等......

DF1:

    Ticker  Type    Std_Week    EOW
    ======  ====    ========    ===
12  OEX     Index   X           NaN
13  XEO     Index   X           NaN
14  SPX     Index   NaN         X
15  XSP     Index   NaN         X

DF2:

    Std_Week             EOW
    ========             ===
0   2018-06-01 00:00:00  2018-06-01 00:00:00
1   NaN                  2018-06-08 00:00:00
2   NaN                  2018-06-22 00:00:00
3   NaN                  2018-06-29 00:00:00
4   NaN                  2018-07-06 00:00:00

0 个答案:

没有答案