[Numpy-discussion] How do I get element on axis 1

Warren Weckesser warren.weckesser@enthought....
Fri Apr 2 16:46:19 CDT 2010


Vishal Rana wrote:
> Hi,
>
> I know its easy, but I am not just getting it...
>
> How do I get last element on axis=1 for:
>
> a = array([[ 0,  1,  2,  3,  4],
>        [ 5,  6,  7,  8,  9],
>        [10, 11, 12, 13, 14],
>        [15, 16, 17, 18, 19],
>        [20, 21, 22, 23, 24]])
>
> Expected: array([4, 9, 14, 19, 24])
>

a[:,-1]

> Thanks
> Vishal Rana
> ------------------------------------------------------------------------
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>   



More information about the NumPy-Discussion mailing list