Полный ответ на основе комментария @Mohit Motwani:
import pandas as pd
df = pd.DataFrame([[1, None, None], [None]*3,[None]*3,
[2,None,None], [None]*3,
[3,None,None], [None]*3, [None]*3, [None]*3,],
columns=["A","B","C"] )
print(df)
df["D"] = df["A"].ffill()
print(df)
Вывод до:
A B C
0 1.0 None None
1 NaN None None
2 NaN None None
3 2.0 None None
4 NaN None None
5 3.0 None None
6 NaN None None
7 NaN None None
8 NaN None None
Вывод после:
A B C D
0 1.0 None None 1.0
1 NaN None None 1.0
2 NaN None None 1.0
3 2.0 None None 2.0
4 NaN None None 2.0
5 3.0 None None 3.0
6 NaN None None 3.0
7 NaN None None 3.0