Last active
September 12, 2019 03:43
-
-
Save rayheberer/c99df6ef296b1a740c2de431dd8fb91f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df_lagged = df.copy() | |
trailing_window_size = 10 | |
for window in range(1, trailing_window_size + 1): | |
shifted = df.shift(window) | |
shifted.columns = [x + "_lag" + str(window) for x in df.columns] | |
df_lagged = pd.concat((df_lagged, shifted), axis=1) | |
df_lagged = df_lagged.dropna() | |
df_lagged.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment