Skip to content
Advertisement

Pandas Dataframe – Shifting rows down and maintaining data

My original Dataframe (df):

JavaScript

I want to shift the values down by 6 like so:

JavaScript

When I use df = df.shift(6), I end up loosing data.

I found this post (How to shift a column in Pandas DataFrame without losing value) but it only seems to work if the values are shifted down by 1.

How can I shift multiple spots down while retaining the data?

Advertisement

Answer

You can try

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement