Created
December 3, 2017 15:24
-
-
Save milo0/b68ab2c609c8792a3a1801dc0fcc7881 to your computer and use it in GitHub Desktop.
Concatenate numpy arrays row-wise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def concatenate_per_row(A, B): | |
m1,n1 = A.shape | |
m2,n2 = B.shape | |
out = np.zeros((m1, m2, n1+n2), dtype=A.dtype) | |
out[:, :, :n1] = A[:, None, :] | |
out[:, :, n1:] = B | |
return out.reshape(m1*m2, -1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment