How to fill the null values with the average of all the preceeding values before null and first succeeding value after null in python?
问题 I have a dataframe with 5000 records. I want the null values to be filled with: Average(All the Preceding values before null, First succeeding value after null) data: Date gcs Comp Clay WTS 2020-01-01 1550 41 9.41 22.6 2020-01-02 1540 48 9.50 25.8 2020-01-03 NAN NAN NAN NAN 2020-01-04 1542 42 9.30 23.7 2020-01-05 1580 48 9.10 21.2 2020-01-06 NAN NAN NAN NAN 2020-01-07 1520 40 10 20.2 2020-01-08 1523 30 25 19 Example: For the date 2020-01-03, i want the null value in the gcs column to be