Given the following data frame:
import pandas as pd import numpy as np df = pd.DataFrame({'A':[1,1,np.nan], 'B':[2.2,np.nan,2.2]}) df A B 0 1.0 2.2 1 1.0 NaN 2 NaN 2.2 If I want to replace the NaN value in column A with the value that repeats in that column (1) and do the same for column B, what sort of fillna() do I need to use?
A B 0 1.0 2.2 1 1.0 NaN 2 NaN 2.2 Looking for a generic solution as I really have thousands of rows. Thanks in advance!