Answers for "pandas shift column down"

2

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)
Posted by: Guest on October-28-2020
0

pandas shift column down

>>> df.shift(periods=3)
#Shifted down by 3 periods
#If you want to shift up insert the number of periods as a negative number
            Col1  Col2  Col3
2020-01-01   NaN   NaN   NaN
2020-01-02   NaN   NaN   NaN
2020-01-03   NaN   NaN   NaN
2020-01-04  10.0  13.0  17.0
2020-01-05  20.0  23.0  27.0
Posted by: Guest on August-06-2021

Code answers related to "pandas shift column down"

Python Answers by Framework

Browse Popular Code Answers by Language