I start with a 2x4 matrix A
import numpy as np
A = np.matrix([[1, 2, 3, 4], [5, 6, 7, 8]])
I also have another 1x4 matrix B
B = np.matrix([9, 10, 11, 12])
How do I concatenate A and B so that I get a 3x4 matrix C
C = [[9 10 11 12]
[1 2 3 4]
[5 6 7 8]]
Note that B is prepended before row 0 of matrix A.
From: http://docs.scipy.org/doc/numpy/reference/routines.array-manipulation.html
C = np.concatenate((B, A))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With