[Numpy-discussion] inserting indexes into an array

Thomas Heller theller at ctypes.org
Wed Sep 24 04:30:24 EDT 2008


I have a numpy array comtaining numbers (a, b, ...), like this:

array([a, b, c, d, e, f])

What is the fastest way to create another array that has the index
of the element before each element of the original array?

The result should look like this:

array([0, a, 1, b, 2, c, 3, d, 4, e, 5, f])

-- 
Thanks,
Thomas




More information about the NumPy-Discussion mailing list