[Numpy-discussion] 2D Arrays column operations

Simon Berube sberub at gmail.com
Thu Mar 29 15:51:46 EDT 2007


Awww, this is quite right. I kept using the a[0][:] notation and I
assume I am simply pulling out single arrays from the array "list".

Thank you very much for the prompt reply. (And sorry for wasting your
time :P)

On Mar 29, 3:46 pm, Travis Oliphant <oliph... at ee.byu.edu> wrote:
> Simon Berube wrote:
> >Hi,
> >   I am relatively new to Python/NumPy switching over from Matlab and
> >while porting some of my matlab code for practice I ran into the
> >following problem.
>
> >Assume we have a 2D Matrix such that
> >a = array([[1, 2, 3],
> >               [4, 5, 6],
> >               [7, 8, 9]])
>
> >If I want the second row I can simply enough take
>
> >c = a[1]
>
> >However, I would like to do a similar operation on the columns of the
> >2D Array. In matlab I could simply do
>
> >c = a(:,2) to get the values array([2,5,8])
>
> c = a[:,2]
>
> -Travis
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discuss... at scipy.orghttp://projects.scipy.org/mailman/listinfo/numpy-discussion




More information about the NumPy-Discussion mailing list