[Numpy-discussion] array manipulation

Alan G Isaac alan.isaac@gmail....
Tue Aug 17 05:50:54 CDT 2010


On 8/17/2010 12:13 AM, Alex 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.


Your ``mat`` is an array.
You get the behavior you seek with NumPy matrices
(although I personally consider is a misfeature).

         >>> m = np.mat(mat)
         >>> m[1]
         matrix([[ 0.95488909,  0.55174423,  0.12103472,  0.15482402,  0.71286625]])

hth,
Alan Isaac




More information about the NumPy-Discussion mailing list