my data as:
id date consumption
1 1/2/2020 500
1 1/3/2020 nan
1 1/4/2020 nan
1 1/5/2020 nan
1 1/6/2020 900
consumption column represents a monthly reading of consumption and is cumulative. i need to distribute consumption 900 on nan cell in (consumption) column and depend on scale factors i had the data i need to be as example like:
id date value
1 1/2/2020 500
1 1/3/2020 650
1 1/4/2020 700
1 1/5/2020 800
1 1/6/2020 900
let's start first by the code for recreating the example data to test on it :
which give us our initial datframe
Next we're going create a list filler, that calculates the values that should be in between ; for our example :
which give us this result :
To get more generic result , we would be looping through the notnull values dataframe , between each two non null values we fill the values as we saw in the example: