[Numpy-discussion] inserting indexes into an array

Nadav Horesh nadavh at visionsense.com
Wed Sep 24 04:47:07 EDT 2008


Possibilities:

column_stack((arange(len(ar)),ar))
 or
transpose((arange(len(ar)),ar)).ravel()

   Nadav.


-----הודעה מקורית-----
מאת: numpy-discussion-bounces at scipy.org בשם Thomas Heller
נשלח: ד 24-ספטמבר-08 11:30
אל: numpy-discussion at scipy.org
נושא: [Numpy-discussion] inserting indexes into an array
 
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

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion at scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 3015 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080924/5d7d8bbc/attachment.bin>


More information about the NumPy-Discussion mailing list