Skip to content

Instantly share code, notes, and snippets.

@BexTuychiev
Created August 3, 2021 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BexTuychiev/b64c8af85c9335bea0d533ac523e2b6d to your computer and use it in GitHub Desktop.
Save BexTuychiev/b64c8af85c9335bea0d533ac523e2b6d to your computer and use it in GitHub Desktop.
time_series = tips[["tip"]]
time_series["lag_1"] = time_series["tip"].shift(1)
time_series["lag_2"] = time_series["tip"].shift(2)
time_series["lag_3"] = time_series["tip"].shift(3)
time_series["lag_4"] = time_series["tip"].shift(4)
# time_series['lag_k'] = time_series['tip'].shift(k)
>>> time_series.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment