How to replace NaNs by preceding or next values in pandas DataFrame?
Suppose I have a DataFrame with some NaNs: >>> import pandas as pd >>> df = pd.DataFrame([[1, 2, 3], [4, None, None], [None, None, 9]]) >>> df 0 1 2 0 1 2 3 1 4 NaN NaN 2 NaN NaN 9 What I need to do is replace every NaN with the first non-NaN … Read more