Skip to content

Instantly share code, notes, and snippets.

@bkaankuguoglu
Created March 15, 2021 22:13
Show Gist options
  • Save bkaankuguoglu/628fa82d3e806f541301ecdab4c9ec5b to your computer and use it in GitHub Desktop.
Save bkaankuguoglu/628fa82d3e806f541301ecdab4c9ec5b to your computer and use it in GitHub Desktop.
def generate_time_lags(df, n_lags):
df_n = df.copy()
for n in range(1, n_lags + 1):
df_n[f"lag{n}"] = df_n["value"].shift(n)
df_n = df_n.iloc[n_lags:]
return df_n
input_dim = 100
df_generated = generate_time_lags(df, input_dim)
df_generated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment