array manipulation-
Gregory Ewing
greg.ewing at canterbury.ac.nz
Sat Aug 21 21:05:07 EDT 2010
Aram Ter-Sarkissov wrote:
> I have an array (say, mat=rand(3,5)) from which I 'pull out' a row
> (say, s1=mat[1,]). The problem is, the shape of this row s1 is not
> [1,5], as I would expect, but rather [5,], which means that I can't,
> for example, concateante mat and s1 rowwise.
Use a 2D slice:
>>> a = array([[1,2],[3,4]])
>>> a
array([[1, 2],
[3, 4]])
>>> b = a[1:2,:]
>>> b
array([[3, 4]])
>>> b.shape
(1, 2)
--
Greg
More information about the Python-list
mailing list