Skip to content

Instantly share code, notes, and snippets.

@atriptoparadise
Created July 27, 2019 13:10
Show Gist options
  • Save atriptoparadise/ec1ba607096b15bee0b11923d61941fa to your computer and use it in GitHub Desktop.
Save atriptoparadise/ec1ba607096b15bee0b11923d61941fa to your computer and use it in GitHub Desktop.
df_timeseries = pd.DataFrame(df.groupby(['Date'])['Amount'].sum()).sort_index(axis=0)
data = pd.DataFrame(df_timeseries.Amount)
data.columns = ["y"]
data = data.loc[data.index[:-1]] # drop data after 2019-06 since we want to predict next half year in 2019
# Adding the lag of the target variable from 7 steps back up to 48 months ago
for i in range(7, 48):
data["lag_{}".format(i)] = data.y.shift(i)
data.tail()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment