python shift code example
Example 1: dataframe shift python
df.shift(2, axis = 0)
df.shift(-2, axis = 0)
df[c1] = df[c2].shift(2, axis = 0)
df[c1] = df[c2].shift(-2, axis = 0)
Example 2: shift in python
shift() is a pandas.DataFrame method that allows you to shift
a line of value by a given number called period.
You can shift along rows, setting axis = 0, or along columns
setting axis = 1. For its complete usage, check the source link.