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

Fabrice Silva silva@lma.cnrs-mrs...
Thu Jun 12 04:21:18 CDT 2008


Le jeudi 12 juin 2008 à 11:11 +0200, Lorenzo Isella a écrit :
> 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]

What about isnan and isinf
import numpy as np
a = np.array([......])
index = (np.isnan(a)==False) & (np.isinf(a)==False)
a = a[index]

-- 
Fabrice Silva <silva@lma.cnrs-mrs.fr>
LMA UPR CNRS 7051 - équipe S2M



More information about the SciPy-user mailing list