How To Fill Nan Value With The Previous Available In The Row?
I need to fill the nan value in a dataframe by using the previous available value in a row, as the data are timeseries. Here there is an example: 1 2 3 4 b b nan c c na
Solution 1:
Use ffill
along the first axis.
df.ffill(axis=1)12340 b b b c1cc d d
2 d d d c
Solution 2:
If you want to fill nan cells by value from row in up:
df.ffill(axis=0)
Post a Comment for "How To Fill Nan Value With The Previous Available In The Row?"