In [2]:
df
Out[2]:
A B C
0 0 0 a
1 0 1 b
2 1 2 c
3 1 3 d
4 2 4 e
5 2 5 f

Use ffill to replace values with the value above them in a column.

0 is not replaced in column A as there is not a valid value above the value.

In [3]:
df.replace([0, 2], method='ffill')
Out[3]:
A B C
0 0 0 a
1 0 1 b
2 1 1 c
3 1 3 d
4 1 4 e
5 1 5 f

Use bfill to replace values with the value below them in a column.

2 is not replaced in column A as there is not a valid value below the value.

In [4]:
df.replace([0, 2], method='bfill')
Out[4]:
A B C
0 1 1 a
1 1 1 b
2 1 3 c
3 1 3 d
4 2 4 e
5 2 5 f