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 9,182 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

## What is the difference between linear regression and logistic regression?

Hi Dev, to answer your question Linear Regression ...READ MORE

## Alternatives to linear regression for dataset with many points with small value and some extreme values

The above situation is the case where ...READ MORE

## Python script for linear regression on panda dataframe

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

## Can someone explain to me the difference between a cost function and the gradient descent equation in logistic regression?

when we train a model with data, ...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

## What is supervised learning?

Supervised learning is the machine learning task ...READ MORE

## Difference between reinforcement learning and supervised learning?

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