Re: [Numpy-discussion] howto convert float array to array of integers

2007-10-05 Thread Alan Isaac
On Fri, 05 Oct 2007, dmitrey wrote: > I have an array like array([ 1., 0., 2., -10.]) > what is most efficient (i.e. fastest) way to convert the one to array of > integers? > array([ 1, 0, 2, -10]) Use ``astype``. Cheers, Alan Isaac >>> import numpy as N >>> x = N.array([1,2,3],dtype='

Re: [Numpy-discussion] howto convert float array to array of integers

2007-10-05 Thread lorenzo bolla
what about astype? a.astype(t) -> Copy of array cast to type t. Cast array m to type t. t can be either a string representing a typecode, or a python type object of type int, float, or complex. L. On 10/5/07, dmitrey <[EMAIL PROTECTED]> wrote: > > hi all, > I have an array like > arra

Re: [Numpy-discussion] howto convert float array to array of integers

2007-10-05 Thread Christopher Hanley
I usually use the astype method. >>> import numpy as n >>> a = n.array([1.,0.,2.,-10.]) >>> a.dtype dtype('float64') >>> print a [ 1. 0. 2. -10.] >>> b = a.astype(n.integer) >>> b.dtype dtype('int32') >>> print b [ 1 0 2 -10] dmitrey wrote: > hi all, > I have an array like > arr

[Numpy-discussion] howto convert float array to array of integers

2007-10-05 Thread dmitrey
hi all, I have an array like array([ 1., 0., 2., -10.]) what is most efficient (i.e. fastest) way to convert the one to array of integers? array([ 1, 0, 2, -10]) Thx in advance, D. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http: