[Numpy-discussion] array gymnastics

Alan Jackson alan at ajackson.org
Thu Sep 11 22:46:35 EDT 2008


Thanks! I think I figured that out about a year ago, and I couldn't
remember what I had done.

On Fri, 12 Sep 2008 04:57:46 +0300
"Nadav Horesh" <nadavh at visionsense.com> wrote:

> or
>  hstack((a.T, b[:,None]))
> 
>    Nadav.
> 
> 
> -----הודעה מקורית-----
> מאת: numpy-discussion-bounces at scipy.org בשם Brent Pedersen
> נשלח: ו 12-ספטמבר-08 04:19
> אל: Discussion of Numerical Python
> נושא: Re: [Numpy-discussion] array gymnastics
>  
> On Thu, Sep 11, 2008 at 6:03 PM, Alan Jackson <alan at ajackson.org> wrote:
> > There has got to be a simple way to do this, but I'm just not seeing it.
> >
> >>>> a = array([[1,2,3,4,5,6],
> >              [7,8,9,10,11,12]])
> >>>> b = array([21,22,23,24,25,26])
> >
> > What I want to end up with is :
> >
> > c = array([[1,7,21],
> >           [2,8,22],
> >            ......
> >           [6,12,26]])
> >
> >
> > --
> > -----------------------------------------------------------------------
> > | Alan K. Jackson            | To see a World in a Grain of Sand      |
> > | alan at ajackson.org          | And a Heaven in a Wild Flower,         |
> > | www.ajackson.org           | Hold Infinity in the palm of your hand |
> > | Houston, Texas             | And Eternity in an hour. - Blake       |
> > -----------------------------------------------------------------------
> > _______________________________________________
> > Numpy-discussion mailing list
> > Numpy-discussion at scipy.org
> > http://projects.scipy.org/mailman/listinfo/numpy-discussion
> >
> 
> hi, i think
> 
> >>> numpy.column_stack((a[0], a[1], b))
> 
> does what you want.
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
> 


-- 
-----------------------------------------------------------------------
| Alan K. Jackson            | To see a World in a Grain of Sand      |
| alan at ajackson.org          | And a Heaven in a Wild Flower,         |
| www.ajackson.org           | Hold Infinity in the palm of your hand |
| Houston, Texas             | And Eternity in an hour. - Blake       |
-----------------------------------------------------------------------



More information about the NumPy-Discussion mailing list