Fellows, so I am trying to come up with code that fill the nan values with value between the previously an next value.
-
It is a plus if we can come up with a value that keeps the natural log of the curve.
data:
df = pd.DataFrame("Weeks": [1,2,3,4,5,6,7,8,10],
"Values": [100,80,nan,nan,nan,69,68,nan,50,40] )
Desired output:
Weeks Values
1 100
2 80
3 nan ? =(should give a value in between)
4 nan ?
5 nan ?
6 69
7 68
# and so on...
Would be even better output (extra):
- it uses Logarithmic interpolation to fill the blanks
- it keeps the natural log of the curve
math:
(Upper Boundary-Lower Boundary) * (Ln(position of blank interval)/ln(total size of the blank intervals)) / 1 ) + Lower Boundary
so like following the example above:
so like Ln(2)/ln(3) for the first one if there's 13 blanks in a row then the next would be ln(3)/ln(13), 13 is the size of how many blanks there are +2 so if theres 1 blank by it self
its ln(2)/ln(3)
Feel welcome to come up with your own formula, the goal is come up replace numbers that will follow the natural log of the curve. But just number that fits between the curve is a valid answer too.