[Numpy-discussion] inserting indexes into an array

Nadav Horesh nadavh@visionsense....
Wed Sep 24 03:47:07 CDT 2008


Possibilities:

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

   Nadav.


-----הודעה מקורית-----
מאת: numpy-discussion-bounces@scipy.org בשם Thomas Heller
נשלח: ד 24-ספטמבר-08 11:30
אל: numpy-discussion@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@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 3015 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080924/5d7d8bbc/attachment.bin 


More information about the Numpy-discussion mailing list