I am looking to multiply element-wise two dataframes with matching indices, using a dictionary to map which columns to multiply together. I can only come up with convoluted ways to do it and I am sure there is a better way, really appreciate the help! thx!
df1:
| Index | ABC | DEF | XYZ |
|---|---|---|---|
| 01/01/2004 | 1 | 2 | 3 |
| 05/01/2004 | 4 | 7 | 2 |
df2:
| Index | Echo | Epsilon |
|---|---|---|
| 01/01/2004 | 5 | 10 |
| 05/01/2004 | -1 | -2 |
Dictionary d = {'ABC': 'Echo', 'DEF': 'Echo', 'XYZ': 'Epsilon'}
Expected result:
| Index | ABC | DEF | XYZ |
|---|---|---|---|
| 01/01/2004 | 5 | 10 | 30 |
| 05/01/2004 | -4 | -7 | -4 |