2

I have the following pandas dataframe "A":

    0   1   2
0  10   5   7
1   5  20  14
2   7  14  30

and the following numpy array "B":

array([1, 2, 3])

I want to perform an element-wise multiplication between "A" and "B":

C = A*B

results in

    0   1   2
0  10  10  21
1   5  40  42
2   7  28  90

Now I want to perform an element-wise multiplication between "C" and transposed (vertical) "B". I tried:

D = C * B.T

and

D = np.multiply(C,np.transpose(B))

but both result in:

    0   1    2
0  10  20   63
1   5  80  126
2   7  56  270

instead of the expected

    0   1    2
0  10  10   21
1  10  80   84
2  21  84  270

What am I doing wrong? Thanks

younggotti
  • 762
  • 2
  • 15

0 Answers0