Pandas Dataframe.shift() Syntax
Syntax:DataFrame.shift(periods=1, freq=None, axis=0)
Parameters :
periods : Number of periods to move, can be positive or negative
freq : DateOffset, timedelta, or time rule string, optional Increment to use from the tseries module or time rule (e.g. ‘EOM’). See Notes
axis : {0 or ‘index’, 1 or ‘columns’}Return : shifted : DataFrame
Python | Pandas dataframe.shift()
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas dataframe.shift() function Shift index by the desired number of periods with an optional time freq. This function takes a scalar parameter called the period, which represents the number of shifts to be made over the desired axis. This function is very helpful when dealing with time-series data.