awswrangler

Pandas merge two DF with rows replacement

半腔热情 提交于 2021-02-17 05:18:25
问题 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': ['id1', 'id2', 'id3', 'id4'], 'com': [134.6, 223, 0, 123], 'malicious': [False, False, True, False] }) df2 = pd.DataFrame({ 'id': ['id7', 'id2', 'id5', 'id6'], 'com': [134.6, 27.6, 0, 123], 'malicious': [False, False, False, False] }) df1 id com malicious 0 id1 134.6 False 1 id2 223.0 False 2 id3 0.0 True 3 id4 123.0 False df2 id com malicious date 0