Fill NaNs With Values & By Series Using Pandas
To fill NaNs with Pandas we can fill with a set value i.e. fill all NaN with zeros.
Alternatively, we can use a Series to fill the gaps. This works by using the value in the row index of the series to fill any corresponding NaNs in the row of the selected dataframe or dataframe column.
In the below examples, we fill df1 NaNs with zeros and fill NaNs in col_A of df2 with the corresponding values in col_B.