[Numpy-discussion] creating column vectors

Gerard Vermeulen gerard.vermeulen at grenoble.cnrs.fr
Wed Feb 8 07:22:04 EST 2006


On Wed, 8 Feb 2006 16:10:52 +0200
Stefan van der Walt <stefan at sun.ac.za> wrote:

> This is probably a silly question, but what is the best way of
> creating column vectors? 'arange' always returns a row vector, on
> which you cannot perform 'transpose' since it has only one dimension.
> 
> mat(arange(1,10)).transpose()
> 
> works, but seems a bit long-winded (in comparison to MATLAB's [1:10]').
> 
> I'd appreciate pointers in the right direction.
> 

What about this?

arange(1, 10)[:, NewAxis]

Gerard




More information about the NumPy-Discussion mailing list