# Change date in linear regression model [closed]

Im trying to run a linear regression model with Years as the x variable and temperature on the y variable but I keep getting errors. I manage to run a regression model using the below code and also predicting for a future date 2040. But what Im struggling with is to change the data so its running from a specific date, 1950 instead of 1880 which is the original start of the data. How do you change the date range in a linear regression model?

sns.regplot('Year','No_Smoothing',data=df)

x=df.Year
y=df.No_Smoothing
np.array(x).reshape((-1,1))

from sklearn.linear_model import LinearRegression
reg =LinearRegression()
reg.fit(df[['Year']],df.No_Smoothing)
reg.predict([[2040]])

• if you're analyzing a time series with regression, you should be aware that you're probably violating the autocorrelation assumption Mar 13 '20 at 19:10

df2 = df.loc[df.Year >= 1950]