How to shift rows

i am using .shift() function to shift rows but while shfiting i am getting all NAN Values, Kindly suggest where i am doing mistaking???

You can use .shift() method to move your rows but that would create rows/columns with NaN values unless specified what exactly do you want to fill.

For shifting: df.shift(periods=1, axis="columns", fill_value=0)
with period you can specify how many columns you needs to shift (it applies to all columns), axis lets you select rows or columns, fill_values can help you to fill specific values.

I’d suggest you to create a new column at the end with the correct sequences and then just drop the old columns.

To Add : df['new_col'] = df['Months']
To Drop : df.drop(['Months'], axis=1)