+ 1

# How do I add these two numpy arrays [1,2,3]+[3,2]?

3 Answers

+ 4

They are different shapes so you cannot add them like this.
If you reshape the first one to be 3x1 instead of 1x3 then it works.
https://code.sololearn.com/cLw3667wlEje/?ref=app

+ 4

Check the numpy documentation for matrix addition. If they are not the same shape, then they must be 'broadcastable' to a common shape. Practically they need to share the dimension along which you add them.
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.add.html

0

Why reshape the first array and not the second?