0

I have two arrays of the following dimensions: a = (6,1) b = (6,4) I wish to add array (a) as additional column to array (c).

Tried: c= np.column_stack([b,a]) and get an error due to mismatch of dimensions.

Path2light
  • 21
  • 1
  • see https://stackoverflow.com/questions/15815854/how-to-add-column-to-numpy-array and https://stackoverflow.com/questions/8486294/how-to-add-an-extra-column-to-an-numpy-array – Don Smythe Nov 01 '16 at 13:03

1 Answers1

1

Try:

c = np.concatenate((b,a), axis=1)

This assumes that a.shape = (6,1). If a.shape = (6,) then you can do:

c = np.concatenate((b,a.reshape((6,1))), axis=1)
Angus Williams
  • 2,284
  • 19
  • 21