Python script for linear regression on panda dataframe

0 votes
I have the following panda dataframe:

    value
0  4354
1  7556
2  609
3  7842

I need to perform linear regression on it. Can I have a python script for this purpose? Thank you
May 23 in Machine Learning by Ishaan
65 views

1 answer to this question.

0 votes

Use the following code:

from scipy import stats
slope, intercept, r_value, p_value, std_err = stats.linregress(df.index, df['value'])
df['linreg'] = intercept + slope * df.index

answered May 23 by Imran

Related Questions In Machine Learning

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

What is rolling linear regression?

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

answered May 23 in Machine Learning by Jinu
70 views
0 votes
1 answer