checking array for NaN values.

Is there an easy way to check an array for NaN values? 'all(array)' regards NaN as true (because it's not 0). I've tried all(array != nan) which didn't work either. When i call locations which i know are NaN, it returns -1.#IND. But if i try to call all(array != -1.#IND), python interprets the # as the start of a comment. Any thoughts? thanks, alex. Alexandra Geddes UC Davis

On Thu, Jan 8, 2009 at 9:15 PM, Alexandra Geddes <mexicalex@yahoo.com> wrote:
Is there an easy way to check an array for NaN values? 'all(array)' regards NaN as true (because it's not 0). I've tried all(array != nan) which didn't work either. When i call locations which i know are NaN, it returns -1.#IND. But if i try to call all(array != -1.#IND), python interprets the # as the start of a comment.
I use
np.any(np.isnan(np.array([1,2,np.nan]))) True
Josef
participants (2)
-
Alexandra Geddes
-
josef.pktd@gmail.com