[EMAIL PROTECTED] wrote: > hello everyone > > would anyone please tell me what is the best (fastest) way of replacing > values in numarray arrays? > > lets say i have an array that may contain 0s, and i just want to get > rid of those 0s by replacing them with another number. what would be > the most efficient way to do that? > > many thanks in advance! > One way to do that is
data2 = numarray.choose(numarray.equal(data,0), (data, another_number)) I am not sure this is the most efficient way. If you get other suggestions, you can compare them with the timeit module. http://www.python.org/doc/2.4.2/lib/module-timeit.html But if you plan to do calculations with the data, I think replacing zeros is not critical for performance. -- http://mail.python.org/mailman/listinfo/python-list