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

Trying to Sort by Values with NaN

I have a dataset that I need to change the NaNs with a value when I do so there is no value stored.
the data looks like this:

 id       type      status    job_id
 1        EMP       Pending      
 1        EMP       Pending     101
 1        Contract  Aproved     391
 2        EMP       Approved    521
 2        Contract  Approved     

This is the code I have tried to use to fill those NaNs

df['job_id'].fillna(0)
df[df['job_id'] == 0] 

When I do this I get nothing to show up and I don’t know why when it should some type of data. But instead this is what I get when I look at only job_id
that equal 0.

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

id    type   status   job_id

Am I using the wrong function or am I missing something? I have pandas and numpy installed as well.

>Solution :

Try this:

df['job_id'].fillna(0, inplace = True)

Otherwise .fillna() returns the following:

Object with missing values filled or None if inplace=True.

Which means you would have to use:

df['job_id']=df['job_id'].fillna(0)
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