[Numpy-discussion] Fast and efficient way to convert an array into binary

frank wang f.yw@hotmail....
Tue Nov 18 14:15:50 CST 2008


Hi,
 
I have a large array and I want to convert it into a binary array. For exampe, y=array([1,2,3]), after the convertion I want the result array([0,0,0,1,0,0,1,0,0,0,1,1]). Each digit is converted into 4 bits in this example. In my real problem I want to convert each digit to 8 bits. My data is numpy.ndarray and the shape is, say, (1000,).
 
Are there fast and efficient solution for this?
 
 
Thanks
 
Frank
_________________________________________________________________
Color coding for safety: Windows Live Hotmail alerts you to suspicious email.
http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_safety_112008 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20081118/4936b9a3/attachment-0001.html 


More information about the Numpy-discussion mailing list