Pandas merge two DF with rows replacement

前端 未结 1 1015
一生所求
一生所求 2021-01-26 13:08

I faced with an issue to merge two DF into one and save all duplicate rows by id value from the second DF. Example:

df1 = pd.DataFrame({
    \'id\':          


        
相关标签:
1条回答
  • 2021-01-26 13:32

    If need unique id with remove values from df1 if exist also in df2 use:

    df = pd.concat([df1, df2]).drop_duplicates('id', keep='last')
    
    0 讨论(0)
提交回复
热议问题