[SciPy-user] How to get rid of nan and Inf

Lorenzo Isella lorenzo.isella at gmail.com
Thu Jun 12 05:11:05 EDT 2008


Dear All,
Say that you have an array which represents the time evolution of
certain quantities as time progresses.
Some entries of this array could be ill-defined (coming from a
division by zero or an indefinite error on a linear regression). How
can you automatically get rid of these?
I am looking for something like:

remove_ill_defined=where(array_ill_defined == is_a_number)
array_well_defined=array_ill_defined[remove_ill_defined]

but I do not know the command to identify a number vs an Inf or a nan
(my fictitious is_a_number condition).
Cheers

Lorenzo



More information about the SciPy-User mailing list