[Numpy-discussion] Backwards slicing including the first element

Chris Barker Chris.Barker at noaa.gov
Wed Mar 10 11:48:34 EST 2010

> Jerome Esteve wrote:
>> Is there a way to give an integer value to j when using a[i:j:-1] so 
>> that the first element of the array can be included in the slice ?

Is this what you are looking for?

In [11]: a = np.arange(10)

In [12]: a[6::-1]
Out[12]: array([6, 5, 4, 3, 2, 1, 0])

I know it's not an integer, but it does indicate "the last (or first) 
element of the array"


Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov

More information about the NumPy-Discussion mailing list