[Numpy-discussion] Standard functions (z-score) on nan (again)

2008-09-25 Thread Peter Saffrey
I've bodged my way through my median problems (see previous postings). Now I
need to take a z-score of an array that might contain nans. At the moment, if
the array, which is 7000 elements, contains 1 nan or more, all the results come
out as nan. 

My other problem is that my array is indexed from somewhere else - position 0
holds the value for a particular id, position 1 holds the value for a particular
id and so on, so if I remove the nans, all the indices are messed up. Can
anybody suggest a sensible fix for this problem?

I know I should really be using masked arrays, but I can't seem to find a
masked-array version of zs. Is there one?

Peter

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Standard functions (z-score) on nan (again)

2008-09-25 Thread Anne Archibald
2008/9/25 Peter Saffrey [EMAIL PROTECTED]:
 I've bodged my way through my median problems (see previous postings). Now I
 need to take a z-score of an array that might contain nans. At the moment, if
 the array, which is 7000 elements, contains 1 nan or more, all the results 
 come
 out as nan.

 My other problem is that my array is indexed from somewhere else - position 0
 holds the value for a particular id, position 1 holds the value for a 
 particular
 id and so on, so if I remove the nans, all the indices are messed up. Can
 anybody suggest a sensible fix for this problem?

 I know I should really be using masked arrays, but I can't seem to find a
 masked-array version of zs. Is there one?

Just keep an array of indices:

c = ~np.isnan(A)

Aclean = A[c]
indices = np.arange(len(A))[c]

Then the original index of Aclean[i] is indices[i].

Anne
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion