Answer by Quang Hoang for Fill NaN based on previous value of row
IIUC, a quick solution without reshaping the data:df.iloc[:,::2] = df.iloc[:,::2].ffill(1)df.iloc[:,1::2] = df.iloc[:,1::2].ffill(1)dfOutput: A B C D E F0 3 4 3 4 3 41 9 8 9 8 9 82 5 9 4 7 4 73 5 7 6 3...
View ArticleAnswer by jezrael for Fill NaN based on previous value of row
Idea is reshape DataFrame for possible forward and back filling missing values with stack and modulo and integer division of 2 of array by length of columns:c = df.columns a =...
View ArticleFill NaN based on previous value of row
I have a data frame (sample, not real):df = A B C D E F 0 3 4 NaN NaN NaN NaN 1 9 8 NaN NaN NaN NaN 2 5 9 4 7 NaN NaN 3 5 7 6 3 NaN NaN 4 2 6 4 3 NaN NaN Now I want to fill NaN values with previous...
View Article
More Pages to Explore .....