Skip to content Skip to sidebar Skip to footer

Joining Pandas Dataframes On Column Name Matches Row Value (with Same Index)

I have data that looks like this: ID Col1 Col2 2018-06-01 'A' 10 100 2018-06-02 'B' 5 25 2018-06-03 'A' 25 25 and another da

Solution 1:

Using lookup

df1['New']=df2.lookup(df1.index,df1.ID)
df1
Out[14]: 
           ID  Col1  Col2  New
2018-06-01  A    10   100  0.5
2018-06-02  B     5    25  2.1
2018-06-03  A    25    25  0.6

Post a Comment for "Joining Pandas Dataframes On Column Name Matches Row Value (with Same Index)"