you are right Eric,

In [405]: b[...,-4:]
Out[405]:
array([[ 6,  7,  8,  9],
       [16, 17, 18, 19]])

cheers,

Chao

2011/10/18 Chao YUE <chaoyue...@gmail.com>

> Thanks Jean
> I just want the last several numbers by indexing from the end.
>
> In [400]: b=np.arange(20).reshape(2,10)
>
> In [401]: b
> Out[401]:
> array([[ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9],
>        [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]])
>
> I want something like b[...,...(index from the end by using negative
> number)] to get:
> array([[ 6,  7,  8, 9],
>        [16, 17, 18, 19]])
>
> but it's strange that if you use b[...,-1],
> you get:
> In [402]: b[...,-1]
> Out[402]: array([ 9, 19])
>
> if use b[...,-4:-1],
> you get:
> Out[403]:
> array([[ 6,  7,  8],
>        [16, 17, 18]])
>
> but you cannot use b[...,-4:-1] to get
> array([[ 6,  7,  8, 9],
>        [16, 17, 18, 19]])
> because
> In [403]: b[...,-4:-1]
> Out[403]:
> array([[ 6,  7,  8],
>        [16, 17, 18]])
>
> I don't know I am more clear this time....
>
> Chao
>
>
> 2011/10/18 Jean-Luc Menut <jeanluc.me...@free.fr>
>
>>  how can I pick up something like:
>>> array([[1, 2, 3, 4],
>>>        [6, 7, 8, 9]])
>>>
>>
>>
>> I'm not sure to understand, should not a[:,1:] be sufficient ?
>> Did I miss something in your message ?
>>
>>
>
>
> --
>
> ***********************************************************************************
> Chao YUE
> Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
> UMR 1572 CEA-CNRS-UVSQ
> Batiment 712 - Pe 119
> 91191 GIF Sur YVETTE Cedex
> Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
>
> ************************************************************************************
>
>


-- 
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to