On Tue, Aug 17, 2010 at 12:13 AM, Alex Ter-Sarkissov <ater1...@gmail.com> wrote: > hi, this is probably a very silly question, but I can't get my hear > around it unfortunately( > > 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.
try np.vstack((mat[0], mat)) np.arrays are not matrices, a slice with a single number reduces dimenson, mat[0] which is identical to mat[0,:] for 2d array mat[0][np.newaxis,:] adds a new (row) dimension >>> mat[0][np.newaxis,:].shape (1, 5) it is described somewhere in the help on slicing and indexing Josef > > thanks for the help > > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > > _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion