I completely forgot about nulls when applying this solution. I want to treat nulls as if they don't exist and continue calculations on non-null values. I tried using various combinations of fills, except 0n, but couldn't figure out how to handle it.
Considering same example and introducing some null values in it, I want to achieve the following:
Ajays approach does precisely this, have you actually tested it?
Alternatively with a little bit of effort you should be able to take either of our suggestions, figure out how they work and then modify them to achieve what you need (use fill ^ within the iterations for example).