[SciPy-user] possibly stupid question
Charles Hebert
charles.hebert at gmail.com
Wed May 16 11:36:52 EDT 2007
Try :
>>> import numpy
>>> a = numpy.arange(100)
>>> b = a[:14]
>>> b
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
>>> c = a[15:]
>>> c
array([15, 16, 17, ....
83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
C.
Trevis Crane a écrit :
>
> Hi,
>
> OK this seems like a really dumb question, but here it is:
>
> I have an array:
>
> a = arrange(1,100)
>
> I want to split it up. I want
>
> b = a[0:15]
>
> c = a[15: to the end of a, inclusive]
>
> Obviously, for the c assignment, I can’t actually write I did. If I do
> this instead:
>
> c = a[15:-1], I actually don’t get the very last element. I can do this:
>
> c = a[15:len(a)]
>
> But that seems cumbersome.
>
> Is there a quick/easy or more elegant way of getting a slice of
> elements that extends to the end of the array but is inclusive of that
> last element?
>
> thanks,
>
> trevis
>
More information about the SciPy-User
mailing list