In the missing value filling, if we fill the middle mean with the mean before and after, for example, 0, empty, 1, we want to fill 0.5 in the middle; or 0, empty, empty, 1, we want to fill 0.33, 0.67 in the middle.
You can use pandas functions to fill, because this is linear interpolation
df..interpolate()
dd=pd.DataFrame(data=[0,np.nan,np.nan,1])
dd.interpolate()
Supplementary knowledge: simple derivation of linear interpolation formula
The above python linear interpolation analysis is all the content shared by the editor, I hope to give you a reference.
Recommended Posts