[Numpy-discussion] replace array values efficiently

Prashant Saxena animator333@yahoo....
Fri Jan 9 01:19:53 CST 2009


I am new to numpy and getting my hands on slowly. 

How do you replace integers from strings in an integer array. (1D)

For example:

array = {1,1,1,2,3,3,4}

replace 1 with "apple"
replace 2 with "cheery"
replace 3 with "mango"
replace 4 with "banana"

I know the general solution, but I am looking for an efficient way, supported by numpy/scipy to do this kind of conversion as fast as possible.



      Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20090109/0ac8212b/attachment-0001.html 

More information about the Numpy-discussion mailing list