My problem is to apply a multiplication factor K=0.5 starting at the first valid number that appears before the missing values "NaN" and keep applying that factor K to the calculated values until the last missing value NaN of the period.
TABLE A:
Bird1 Bird2 Bird3
100 50 200
50 40 100
40 40 80
NaN 80 200
NaN 50 NaN
NaN 90 NaN
100 12 40
The result should be as per the table below. How to implement this code in python?
TABLE B:
Bird1 Bird2 Bird3
100 50 200
50 40 100
40 40 80
20 80 200
10 50 100
5 90 50
100 12 40
Using the df.interpolate() command is not suitable because it also uses the value after the missing values NaN. I would just like a constant K starting and being applied to the first value BEFORE the missing values NaN.