1

I need help to process the following operation : I would like to create a new df by multiplying the value in key_3 (int) in df1 by the % in df2 so that I will get 4 columns instead of 1 with an allocation based on % df2.

df1
key key_2 key_3
aaa bbb value int

df2
key key_2 key_3 e1 e2 e3 e4
aaa bbb str value % % % %

Thank you for your help !

MinatoDBO
  • 45
  • 1
  • 7
  • [Do not post your data as images](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors). – Quang Hoang Feb 09 '23 at 17:47
  • Can create a dataframe construction with mock data and expected output? – Scott Boston Feb 09 '23 at 18:14
  • This question is answered [here](https://stackoverflow.com/questions/22702760/how-to-multiply-multiple-columns-by-a-column-in-pandas); use `df3 = df2.multiply(df1.key_3, axis="index")` – Joshua Voskamp Feb 09 '23 at 18:22
  • it's not same because in my case I have key_3 in df1 which contains an integer I would like to multiply this value by e1,e2, etc. knowing that the value of key_3 in my df2 is the name of the columns in df1 – MinatoDBO Feb 10 '23 at 09:19

0 Answers0