fill NaN based on other columns value

I have a data frame like this :

NAME    YEAR    WFR MEAN
0   A   2017    20  NaN
1   B   2009    50  65.0
2   B   2011    80  65.0
3   B   2017    60  65.0
4   B   2018    90  NaN
5   C   2010    10  10.0
6   C   2018    30  10.0
7   D   2014    40  47.5
8   D   2015    55  47.5
9   D   2016    45  47.5

I want to fill the NaN with the value of WFR: if the MEAN was NaN then the MEAN is equal to the value of WFR in that year .
any idea ? Thanks

>Solution :

Try this:

df['MEAN'] = df['MEAN'].fillna(df['WFR'])

Leave a Reply