Skip to content Skip to sidebar Skip to footer

Shift Entire Column On A Pandas Dataframe

I want to shift to the right an entire column, fill with NAN the first column and drop the last column: df0: A B C D 2013-12-31 10 6 6 5 2014-01-

Solution 1:

shift shift the data by rows. Here's my trick

df.T.shift().T

Update

It's a bug when passing axis as 1. It's been solved in the current develop version. If you are living in the cutting edge, use

df.shift(axis=1)

instead.

Post a Comment for "Shift Entire Column On A Pandas Dataframe"