thanks Scott. very good explanation.
cheers,
Chao
2011/10/18 Scott Sinclair
> On 18 October 2011 13:56, Chao YUE wrote:
> > 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]:
>
On 18 October 2011 13:56, Chao YUE wrote:
> 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]])
That's because you're mixing two different indexing c
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
> 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
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
Le mardi 18 octobre 2011 13:44:00, Chao YUE a écrit :
> 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]])
>
>
> 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 ?
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http:
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 s