Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try this:

df['MEAN'] = df['MEAN'].fillna(df['WFR'])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading