[Tutor] reclassify values in an array

Sander Sweers sander.sweers at gmail.com
Thu Sep 1 10:12:03 CEST 2011

On Thu,   1 Sep 2011, 01:17:45 CEST, questions anon <questions.anon at gmail.com> wrote:

> Firstly just make them zeros and ones, for example if the values in the
> array are less than 100 make them 0 and if greater than 100 make them 1.
> And then finally sum them together.
> I have attempted a few methods, see code below. Any feedback will be
> greatly appreciated.

*If* you do not need the array after you summed you can do something like below (untested!):

big_array = N.ma.concatenate(all_FFDI)
rusult = 0

for i in big_array:
    if i >= 100:
        result += 1

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110901/0d406101/attachment.html>

More information about the Tutor mailing list