Reputation: 1491
I have a numpy matrix
1 2
3 4
I want to 'concatenate' the rows of the matrix to get a new matrix
13 24
Is there a simple way to do this?
Upvotes: 0
Views: 786
Reputation: 353109
Looks to me more like you want to concatenate the columns. Maybe something like this would suffice?
In [25]: import numpy as np
In [26]: a = np.array([[1,2],[3,45]])
In [27]: a
Out[27]:
array([[ 1, 2],
[ 3, 45]])
In [28]: [''.join(str(x) for x in row) for row in a.T]
Out[28]: ['13', '245']
In [29]: np.array([''.join(str(x) for x in row) for row in a.T], int)
Out[29]: array([ 13, 245])
Upvotes: 1