Is there a way to ignore the NaN and do the linear regression on remaining values?

```val=([0,2,1,'NaN',6],[4,4,7,6,7],[9,7,8,9,10])
time=[0,1,2,3,4]
slope_1 = stats.linregress(time,values) # This works
slope_0 = stats.linregress(time,values) # This doesn't work``` May 22, 2019 6,064 views

## 1 answer to this question.

Yes, you can do this using statsmodels:

```import statsmodels.api as sm
from numpy import NaN
x = [0, 2, NaN, 4, 5, 6, 7, 8]
y = [1, 3, 4,   5, 6, 7, 8, 9]
model = sm.OLS(y, x, missing='drop')
results = model.fit()
In : results.params
Out: array([ 1.16494845])``` answered May 22, 2019 by Hari

## Python script for linear regression on panda dataframe

Use the following code: from scipy import stats slope, ...READ MORE

## Python code for basic linear regression

Hi @Dipti, you could try something like ...READ MORE

## What is rolling linear regression?

Rolling regression is the analysis of changing ...READ MORE

## Show python implementation of Lasso class - regression

Hey @Tanmay, try something like this: >>> from ...READ MORE

## Can you give LassoLars python example?

Hey @Vivek, Try something like this: >>> from ...READ MORE

## Difference between reinforcement learning and supervised learning?

In reinforcement learning, the output depends on ...READ MORE