I would like to add a second Integer column, b, whose value is 1 for the first row and, for the other rows, takes the result of a function that requires inputs from the previous row, as well as the current row.
Pseudo code: df.b = if first row then 1 else (if df.a < 0.5 then previous row's df.b else previous row's df.b + 1)
Thank you.
I was also thinking about cloning the a column and shift it 1 row, but that would be inefficient and after all avoiding the loop wouldn’t make my code more elegant anyway
If I create a ShiftedArray for a DataFrame column, would the shifted array be a copy of the data frame column?
I guess this question is equivalent to asking if data frame columns are backed by arrays as their storage representation