Let's define a data frame from your example
>>> df = pd.DataFrame([[206, 214], [226, 234], [245, 253], [265, 272], [283, 291]], columns=[1, 2]) >>> df 1 2 0 206 214 1 226 234 2 245 253 3 265 272 4 283 291
Then you can manipulate the index of the second column with
>>> df[2].index = df[2].index+1
and finally re-merge the individual columns
>>> pd.concat([df[1], df[2]], axis=1) 1 2 0 206.0 NaN 1 226.0 214.0 2 245.0 234.0 3 265.0 253.0 4 283.0 272.0 5 NaN 291.0
Perhaps not fast, but just for reading. Consider setting variables for column names and the actual offset required.
Edit: As a rule, a shift is possible using df[2].shift(1) as it has already been published, however, this will lead to a cutoff of the transfer.
Kay Wittig Jul 09 '18 at 18:22 2018-07-09 18:22
source share