I have the following df:
from to
5 7
8 10
I am trying to get the following output:
from to zip_1 zip_2 zip_3 zip_4
5 8 5 6 7 8
9 10 9 10
I tried the following code but resulted in an error.
for index, row in df.iterrows():
zip_index = 0
colName = 'zip' + '_' + str(zip_index)
while row(colName) != row.To:
zip_index = zip_index + 1
NewCol = 'zip' + '_' + str(zip_index)
row(NewCol) = row(colName) + 1
colName = NewCol
What am I missing?
Thanks!