Trying to Sort by Values with NaN

Question:

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.

id    type   status   job_id

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

Asked By: That_non_coder

||

Answers:

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)
Answered By: tetris programming
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.