Change date in linear regression model 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]])
Slice your DataFrame accordingly, and then apply your previous routine (you may want to put this in a function) to this part of the data:

df2 = df.loc[df.Year &gt;= 1950]