I'm trying to change the values in a DataFrame based on the columns of another DataFrame. The code looks like this:
First dataframe:
df1 = pd.DataFrame({'Ticker':['M2NS Index', 'ECMSM2 Index','A23 VWYH Index'], 'Factor':[4,3,2]})
df1
Ticker Factor
0 M2NS Index 4
1 ECMSM2 Index 3
2 A23 VWYH Index 2
Second dataframe:
df2 = pd.DataFrame({'M2NS Index':[5,2,1], 'ECMSM2 Index':[5,2,1], 'A23 VWYH Index':[5,2,1]})
df2
M2NS Index ECMSM2 Index A23 VWYH Index
0 5 5 5
1 2 2 2
2 1 1 1
I'm want to multiply the row values with 10^factor, where the factor is in the first table. Different columns will multiply with the associated factor. My resulting frame would look like:
df3 = pd.DataFrame({'M2NS Index':[50000,20000,10000], 'ECMSM2 Index':[5000,2000,1000], 'A23 VWYH Index':[500,200,100]})
df3
M2NS Index ECMSM2 Index A23 VWYH Index
0 50000 5000 500
1 20000 2000 200
2 10000 1000 100
If anyone has any idea on how to multiply without using location but rather indexing that would be great! The order of the columns in the second dataframe might be different from the order of the rows in the first dataframe. Any help would be appreciated!