Removing nan values from an array,x = x[~numpy.isnan(x)]