I have two dataframes that have the same structure/indexes.
df1 = pd.DataFrame({
'id': [1, 2, 3, 4, 5],
'column_a': [5, 4, 3, 2, 1],
'column_b': [5, 4, 3, 2, 1],
'column_c': [5, 4, 3, 2, 1]
})
df1.set_index('id', drop=False, inplace=True)
and
df2 = pd.DataFrame({
'id': [1, 2, 3, 4, 5],
'column_a': [5, 4, 3, 2, 1],
'column_b': [5, 4, 3, 2, 1],
'column_c': [5, 4, 10, 2, 1]
})
df2.set_index('id', drop=False, inplace=True)
And I would like to get this result:
expected = pd.DataFrame({'id': [3], 'column_a': [3], 'column_b': [3], 'column_c': [10]})
I tried using for-loop, but I need to deal with a large data load, and it didn't become so performant...