Replace data from one pandas dataframe to another

后端 未结 2 538
耶瑟儿~
耶瑟儿~ 2021-01-05 23:36

I have two dataframes df1 and df2 . They both contain time-series data, so it is possible some of the dates in df1 and df2 intersect with each other and the rest don\'t. My

2条回答
  •  忘掉有多难
    2021-01-06 00:04

    I just saw this question and realized it is almost identical to one that I just asked today and that @Alexander (the poster of the answer above) answered very nicely:

    pd.concat([df1[~df1.index.isin(df2.index)], df2])
    

    See pandas DataFrame concat / update ("upsert")? for the discussion.

提交回复
热议问题