I would like to do the following in python
Basically I have a table as following with y = 0.5
A | B | Result from column A
---
1 2 0.5
---
2 4 0.5*(0.5+ 2)
---
3 5 ...
---
4 4 ...
---
So far I have a loop, which is not efficient, I would like a vectorised way of doing it :
X = np.zeros((len(df),))
for i, (_, row) in enumerate(df.iterrows()):
if i == 0:
continue
X[i] = y*(X[i - 1] + row['A'])
Can you please help me on the above
Thank you