Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Giorgio F. Gilestro
BTW, I found nanmean and nanstd in scipy.stats.stats will be good for my case too. On 6/25/07, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > On 6/25/07, Giorgio F. Gilestro <[EMAIL PROTECTED]> wrote: > > Masked array seems definitely to be the way to go, thanks a lot. > > > > I must say that

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Charles R Harris
On 6/25/07, Giorgio F. Gilestro <[EMAIL PROTECTED]> wrote: Masked array seems definitely to be the way to go, thanks a lot. I must say that this entire issue doesn't make much sense to me: my understanding is the a NaN is different from an INF, therefore one would assume that really there is no

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Robert Kern
Giorgio F. Gilestro wrote: > Masked array seems definitely to be the way to go, thanks a lot. > > I must say that this entire issue doesn't make much sense to me: my > understanding is the a NaN is different from an INF, therefore one > would assume that really there is no reason why a not-number

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Giorgio F. Gilestro
Masked array seems definitely to be the way to go, thanks a lot. I must say that this entire issue doesn't make much sense to me: my understanding is the a NaN is different from an INF, therefore one would assume that really there is no reason why a not-number should not be ignored by default by a

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Pierre GM
On Monday 25 June 2007 14:15:20 Giorgio F. Gilestro wrote: > Thanks. > Actually those I care the most are average and std. > Is there a way to know the number of NaN in an array? Giorgio, You could use: numpy.isnan(x).sum() But once again masked arrays were designed to handle this kind of situa

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Andrew Straw
Giorgio F. Gilestro wrote: > I find myself in a situation where an array may contain not-Numbers > that I set as NaN. > Yet, whatever operation I do on that array( average, sum...) will > threat the NaN as infinite values rather then ignoring them as I'd > like it'd do. > > Am I missing something?

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Robert Kern
Giorgio F. Gilestro wrote: > Thanks. > Actually those I care the most are average and std. > Is there a way to know the number of NaN in an array? isnan(a).sum() -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad att

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Giorgio F. Gilestro
Thanks. Actually those I care the most are average and std. Is there a way to know the number of NaN in an array? On 6/25/07, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > > > > On 6/25/07, Giorgio F. Gilestro <[EMAIL PROTECTED]> wrote: > > I find myself in a situation where an array may contai

Re: [Numpy-discussion] average of array containing NaN

2007-06-25 Thread Timothy Hochberg
On 6/25/07, Giorgio F. Gilestro <[EMAIL PROTECTED]> wrote: I find myself in a situation where an array may contain not-Numbers that I set as NaN. Yet, whatever operation I do on that array( average, sum...) will threat the NaN as infinite values rather then ignoring them as I'd like it'd do.

[Numpy-discussion] average of array containing NaN

2007-06-25 Thread Giorgio F. Gilestro
I find myself in a situation where an array may contain not-Numbers that I set as NaN. Yet, whatever operation I do on that array( average, sum...) will threat the NaN as infinite values rather then ignoring them as I'd like it'd do. Am I missing something? Is this a bug or a feature? :-)