`I'm trying to add incremetal values for each id in this pandas dataframe initial table
id col1 col2
1 0.12 10
1 0.23 20
1 1.1 30
2 0.25 10
2 2.1 20
2 1.2 30
what i want to acheive
id col1 col2
1 0.12 10
1 0.23 20
1 1.1 30
1 0 40
1 0 50
2 0.25 10
2 2.1 20
2 1.2 30
2 0 40
2 0 50
i tried :
def func(row):
for i in row["id"]:
for j in range(40,50+1,10):
row["id"] = i
row["col1"] = 0
row["col2"] = j
df = df.apply(lambda row:func(row))
but this raise an error that id doesn't exist
KeyError: 'id'