I know there are questions similar to this but they do not answer my question, so kindly bear with me.
I have 2 data frames df1 and df2.
In df1, the Order ID1 is the index and the Payment column is empty.
print(df1)
Order ID1 Sale Price Payment
OD1 45
OD2 55
OD3 56
In df2, the Order ID2 is the index.
print(df2)
Order ID2 paid value
OD1 44
OD3 41
OD2 33
I am trying to map the index of df1 (Order ID1) to the index of df2 (Order ID2) and return the corresponding paid value in the empty payment column. Basically I am performing a look up procedure.
I tried using the map function as follows:-
df2['Payment'] = df2.index.map(df1.index)
but I am getting the following error:
TypeError: 'Index' object is not callable
pandas.mergeto join the two DataFrames on the ID column. This would give you a new DataFrame with all three columns.