[Numpy-discussion] index the last several members of a ndarray
Chao YUE
chaoyuejoy at gmail.com
Tue Oct 18 07:44:00 EDT 2011
Dear all,
if I have
In [395]: a
Out[395]:
array([[0, 1, 2, 3, 4],
[5, 6, 7, 8, 9]])
In [396]: a[...,-1]
Out[396]: array([4, 9])
In [397]: a[...,-4:-1]
Out[397]:
array([[1, 2, 3],
[6, 7, 8]])
In [398]: a[...,-4:0]
Out[398]: array([], shape=(2, 0), dtype=int64)
how can I pick up something like:
array([[1, 2, 3, 4],
[6, 7, 8, 9]])
I want to index the final 4 rows. I cannot figure out how to do this?
Thanks for any help,
Chao
--
***********************************************************************************
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
************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20111018/20ad9b0f/attachment.html>
More information about the NumPy-Discussion
mailing list