I have one column in my Dataframe and I am trying to calculate the energy loss with formula. Problem is that I want to use only two valid rows each time where values are not NaN. Energy is the input column and looking for something like loss column.
| Energy | loss |
|---|---|
| NaN | Nan |
| NaN | Nan |
| NaN | Nan |
| 4 | Nan |
| NaN | Nan |
| 3 | 1/2(4^2-3^2) |
| NaN | Nan |
| 11 | Nan |
| 3 | 1/2(3^2-11^2) |
| NaN | NaN |
| 14 | Nan |
I tried Lambda custom function but not able to send the next row.