I have a large data set, and I have some missing value, I want to fill the NAN values by the mean of the column before and after , and in certain cases i have NaN values consecutive in these case I want to replace all this nan values by the first value of non nan can found for examples : I should use a loop
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
19.0 NaN NaN NaN 29.0 30.0 NaN 16.0 15.0 16.0 17.0 NaN 28.0 30.0 NaN 28.0 18.0
The goal is for the data to look like this:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
19.0 29.0 29.0 29.0 29.0 30.0 23.0 16.0 15.0 16.0 17.0 22.5 28.0 30.0 29 28.0 18.0