Suppose I have a pandas series with several consecutive NaNs. I know that fillna has several methods for filling in missing values ( backfill and fill forward ), but I want to fill them with the nearest value other than NaN. Here is an example of what I have:
`s = pd.Series([0, 1, np.nan, np.nan, np.nan, np.nan, 3])`
And an example of what I want: s = pd.Series([0, 1, 1, 1, 3, 3, 3])
Does anyone know that I can do this?
Thanks!
source share