I have the following dataframe:
| col1 | col2 | col3 |
| 5 | 3 | 9 |
| NaN | 6 | NaN |
| NaN | 3 | 7 |
| 7 | 8 | 5 |
| NaN | 3 | NaN |
| 2 | 2 | 4 |
And I want value NaN to be filled with the conditional mean of previous and next value based on the same column.
| col1 | col2 | col3 |
| 5 | 3 | 9 |
| 6 | 6 | 8 |
| 6 | 3 | 7 |
| 7 | 8 | 5 |
| 4.5 | 3 | 4.5 |
| 2 | 2 | 4 |
Just like this, value 6 is the mean with 5 and 7. And this is a little part of my dataframe, so I need to replace all the NaN.