On Sun, May 13, 2007 at 02:36:39PM +0300, dmitrey wrote:
> i.e. for example from flat array [1, 2, 3] obtain
> array([[ 1.],
>        [ 2.],
>        [ 3.]])
> 
> I have numpy v 1.0.1
> Thx, D.

Use newaxis:

In [1]: a = array([1., 2., 3.])
In [2]: a
Out[2]: array([ 1.,  2.,  3.])
In [3]: a[:,newaxis]
Out[3]: 
array([[ 1.],
       [ 2.],
       [ 3.]])
In [4]: a[newaxis,:]
Out[4]: array([[ 1.,  2.,  3.]])

When newaxis is used as an index, a new axis of dimension 1 is added.

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke                      http://arbutus.physics.mcmaster.ca/dmc/
|[EMAIL PROTECTED]
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to