[SciPy-user] How does concatenate work?
iCy-fLaME
icy.flame.gm@gmail....
Thu Jul 5 02:36:24 CDT 2007
If I have a (m, n) array, is concatenate is right way to go about
making it a (m+1, n) or (m, n+1) array?
I tried the following, couldn't figure out how to do it correctly. Any
helps are greatly appreciated.
>>> from numpy import linspace, zeros
>>> from numpy import concatenate
>>>
>>> a = linspace(1, 20, 20).reshape((5,4))
>>> a
array([[ 1., 2., 3., 4.],
[ 5., 6., 7., 8.],
[ 9., 10., 11., 12.],
[ 13., 14., 15., 16.],
[ 17., 18., 19., 20.]])
>>>
>>> b = zeros(4)
>>> b
array([ 0., 0., 0., 0.])
>>>
>>> concatenate((a,b), axis=0)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: arrays must have same number of dimensions
>>>
>>> concatenate((a,b), axis=1)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: arrays must have same number of dimensions
icy
More information about the SciPy-user
mailing list