Re: [Numpy-discussion] howto make from flat array (1-dim) 2-dimensional?
or: a=array([1,2,3]).reshape((-1,1)) Darn, I guess there is more than one obvious way to do it! -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] howto make from flat array (1-dim) 2-dimensional?
On Sun, May 13, 2007 at 07:46:47AM -0400, Darren Dale wrote: > On Sunday 13 May 2007 7:36:39 am dmitrey wrote: > > i.e. for example from flat array [1, 2, 3] obtain > > array([[ 1.], > >[ 2.], > >[ 3.]]) > > a=array([1,2,3]) > a.shape=(len(a),1) Or just a.shape = (-1,1) Cheers Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] howto make from flat array (1-dim) 2-dimensional?
On Sunday 13 May 2007 7:36:39 am dmitrey wrote: > i.e. for example from flat array [1, 2, 3] obtain > array([[ 1.], >[ 2.], >[ 3.]]) a=array([1,2,3]) a.shape=(len(a),1) ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] howto make from flat array (1-dim) 2-dimensional?
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
[Numpy-discussion] howto make from flat array (1-dim) 2-dimensional?
i.e. for example from flat array [1, 2, 3] obtain array([[ 1.], [ 2.], [ 3.]]) I have numpy v 1.0.1 Thx, D. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion