I want to iterate through df and calculate the column a values which needs column b and c values. The formula is like this:
for i in range(1, len(df)):
df.a[i] = df.b[i-1]*(2**df.c[i])
df.b[i] = df.a[i]*0.5 + 1
I want to have faster calculations maybe using apply func or lambda func, but I don't know when I define apply function in python, how can I access previous row's value?
Example input (df.a[0] df.b[0] df.c) and expected output df.a: df
a b c
0 1 1
4 3 2
24 13 3
208 105 4