dragan savic (el 2007-11-12 a les 08:36:25 -0800) va dir:: > I have a question regarding numpy arrays. > Lets say I have two arrays: > > a = array([1,2,3],dtype=float32) > b = array([4,5,6],dtype=int16) > > I want to build a new array like this: > new_array = hstack((row_stack(a),row_stack(b))) > > The result is: > array([[ 1., 4.], > [ 2., 5.], > [ 3., 6.]], dtype=float32) > > What I was hoping was that the elements from the b > array remain int16. Is it possible to have homogeneous > array in numpy?
Maybe you where looking for an *heterogeneous* array (i.e. record array or table)? In that case, the ``numpy.rec`` module is your friend: >>> numpy.rec.fromarrays((a, b)) recarray([(1.0, 4), (2.0, 5), (3.0, 6)], dtype=[('f0', '<f4'), ('f1', '<i2')]) (Or maybe you wanted to post to [EMAIL PROTECTED]) :: Ivan Vilata i Balaguer >qo< http://www.carabos.com/ Cárabos Coop. V. V V Enjoy Data ""
signature.asc
Description: Digital signature
------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________ Pytables-users mailing list Pytables-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pytables-users