Skip to content

Instantly share code, notes, and snippets.

Created Aug 3, 2021
What would you like to do?
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