I have this data frame:
'C1'|'C2'
0 | x
1 | x1
1 | x2
2 | x3
0 | y
1 | y1
2 | y2
0 | z
1 | z1
I need to create an extra column like this:
'C1'|'C2'|'C3'
0 | x | x
1 | x1 | x
1 | x2 | x
2 | x3 | x
0 | y | y
1 | y1 | y
2 | y2 | y
0 | z | z
1 | z1 | z
Basically when ever I find 0 in the C1 column, I have to put in all the sub rows (until the next 0) the corresponding value from the C2 column.
I am new to Pandas and I read that I should avoid manipulating the data frame using iterations.
How can a get this result without iterating? Is it possible?