I have a data frame with a column named SAM with the following data
SAM 3 5 9 Nan Nan 24 40 Nan 57
Now I want to insert 12 , 15 and 43 respectively, into the Nan values ββ(because 9+3=12 , 12+3=15 and 40+3=43 ). In other words, fill out any Nan line by adding 3 to the previous line (which could also be Nan ).
I know that this can be done by iterating through a for loop. But can we do this in vector form? Like some modified version of ffill (which could be used here if we didn't have sequential pandas.fillna() ) in pandas.fillna() .
source share