0

I would like to merge two dataframe by timestamp. But the timestamp column have the same name, but are a little different, here my piece of dataframe: df1:

                         Timestamp   Flag        Group
1438    2019-10-25 10:39:58.352073  begin         prod
1439    2019-10-25 10:40:06.266782    end         prod
1440    2019-10-25 16:35:22.485574  begin        clean
1441    2019-10-27 09:50:31.713192    end        clean
1442    2019-10-28 14:04:33.095633  begin    transport
1443    2019-10-28 14:05:07.639344    end    transport

df2:

                         Timestamp
1438    2019-10-25 10:39:58.352073
1439    2019-10-25 10:40:06.266782
1440    2019-10-25 16:35:22.485574
1441    2019-10-25 17:00:00.000000
1442    2019-10-26 07:00:00.000000
1443    2019-10-26 17:00:00.000000
1444    2019-10-27 07:00:00.000000
1445    2019-10-27 09:50:31.713192
1446    2019-10-28 14:04:33.095633
1447    2019-10-28 14:05:07.639344

The result must be:

                         Timestamp   Flag      Group
1438    2019-10-25 10:39:58.352073  begin       prod
1439    2019-10-25 10:40:06.266782    end       prod
1440    2019-10-25 16:35:22.485574  begin      clean
1441    2019-10-25 17:00:00.000000    NaN        NaN       
1442    2019-10-26 07:00:00.000000    NaN        NaN
1443    2019-10-26 17:00:00.000000    NaN        NaN
1444    2019-10-27 07:00:00.000000    NaN        NaN
1445    2019-10-27 09:50:31.713192    end      clean
1446    2019-10-28 14:04:33.095633  begin  transport
1447    2019-10-28 14:05:07.639344    end  transport

I tried with concatenate but, there is a problem of unicity between the two columns named timestamp. So I don't know how to fix this...

Nadhir
  • 528
  • 3
  • 12

0 Answers0