You can remove NaNs using a mask:
mask = ~np.isnan(varx) & ~np.isnan(vary)
slope, intercept, r_value, p_value, std_err = stats.linregress(varx[mask], vary[mask])
More Related Contents:
- How to make scipy.interpolate give an extrapolated result beyond the input range?
- Sorting arrays in NumPy by column
- Moving average or running mean
- How to do exponential and logarithmic curve fitting in Python? I found only polynomial fitting
- How to smooth a curve in the right way?
- How to solve a pair of nonlinear equations using Python?
- How to normalize a NumPy array to within a certain range?
- Save / load scipy sparse csr_matrix in portable data format
- Find matching rows in 2 dimensional numpy array
- numpy.where() detailed, step-by-step explanation / examples [closed]
- Resampling a numpy array representing an image
- How can I use numpy.correlate to do autocorrelation?
- How to plot empirical cdf (ecdf)
- Most efficient way to sort an array into bins specified by an index array?
- Get coordinates of local maxima in 2D array above certain value
- how to annotate heatmap with text in matplotlib
- scipy is not optimizing and returns “Desired error not necessarily achieved due to precision loss”
- How to share numpy random state of a parent process with child processes?
- How do I calculate r-squared using Python and Numpy?
- Generating Discrete random variables with specified weights using SciPy or NumPy
- Distance between point and a line (from two points)
- Fastest pairwise distance metric in python
- NumPy: Logarithm with base n
- How to get the indices list of all NaN value in numpy array?
- Equivalent of `polyfit` for a 2D polynomial in Python
- setting spacing between grouped bar plots in matplotlib
- Compute a confidence interval from sample data assuming unknown distribution
- Numpy transpose of 1D array not giving expected result
- Fit mixture of two gaussian/normal distributions to a histogram from one set of data, python
- Speedup scipy griddata for multiple interpolations between two irregular grids