I have a pandas.DataFrame of the form
index df df1
0 0 111
1 1 111
2 2 111
3 3 111
4 0 111
5 2 111
6 3 111
7 0 111
8 2 111
9 3 111
10 0 111
11 1 111
12 2 111
13 3 111
14 0 111
15 1 111
16 2 111
17 3 111
18 1 111
19 2 111
20 3 111
I want to create a dataframe in which column df repeats 0,1,2,3. But there is something missing in the data. I'm trying to fill in the blanks with 0 by appending row values. Here is my expected result:
index df df1
0 0 111
1 1 111
2 2 111
3 3 111
4 0 111
5 1 0
6 2 111
7 3 111
8 0 111
9 1 0
10 2 111
11 3 111
12 0 111
13 1 111
14 2 111
15 3 111
16 0 111
17 1 111
18 2 111
19 3 111
20 0 0
21 1 111
22 2 111
23 3 111
How can I achieve this?
edit:
What should I do if my input is as below?
index df1 df2
0 0 111
1 1 111
2 2 111
3 3 111
4 0 111
5 3 111
6 1 111
7 2 111
Here is my expected result:
index df1 df2
0 0 111
1 1 111
2 2 111
3 3 111
4 0 111
5 1 0
6 2 0
7 3 111
8 0 0
9 1 111
10 2 111
11 3 0