[Numpy-discussion] replace array values efficiently

Prashant Saxena animator333 at yahoo.com
Fri Jan 9 02:19:53 EST 2009


Hi,

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.

Thanks

Prashant



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


More information about the NumPy-Discussion mailing list