For example, I want get right from left DataFrame like on picture (move column B on 2 steps down):
PS. "Na" is not necessary, it can be any controlled value like null, zero or empty string.
You can use the .shift
method for this:
df["B"] = df["B"].shift(2)
The value used for the first two rows (NA or something else) can be controlled using the fill_value
argument.