[Numpy-discussion] force column vector
Wed Feb 7 09:11:01 CST 2007
> when creating an ndarray from a list, how can I force the result to be
> 2d *and* a column vector? So in case I pass a nested list, there will be no
> modification of the shape and when I pass a simple list, it will be
> converted to a 2d column vector. I can only think of a solution using 'if'
> clauses but I suppose there is a more elegant way.
I'd be interested if you find a way without a single 'if'; I can't think
of any, sorry. (which doesn't mean much, however... :-)
Maybe your best bet is to make sure the lists are always nested at the
source, if you have any control over that particular source.
More information about the Numpy-discussion