0

I have two numpy arrays of the shapes (4, 1) and (4,) respectively. I want to add these two arrays the conventional way to get an array with four elements. For example,

A = np.array([[3],[5],[4],[2]])
B = np.array([3,5,4,2])

I want C= A+B to be np.array([6,10,8,4]) (preferably of the shape (4,). But when, I add these two arrays (A and B), I get a 4*4 matrix.

print A+B
[[  6.   8.   7.   5.]
 [  8.  10.   9.   7.]
 [  7.   9.   8.   6.]
 [  5.   7.   6.   4.]]

What am I missing and how can I achieve the functionality that I am aiming for?

Commoner
  • 1,678
  • 3
  • 19
  • 34

0 Answers0