Jupyter notebook project

Screen Link:

My Code:

       tafe_resignations['Contributing Factors. Dissatisfaction'].value_counts().sort_index(ascending= True) 
       tafe_resignations['Contributing Factors. Job Dissatisfaction'].value_counts().sort_index(ascending= True) 
def update_vals(value):
   if value == 'NaN':
       return np.nan
   if value == '-':
       return false
       return true

What I expected to happen:

Replace this line with the code output you expected to get

What actually happened:

Replace this line with the actual output/error

I am having a hard time trying to write the function. I feel like I am on the right path, but I want some guidance. How would I be able to incorporate the pd.isnull(val) into the function. Also, should I have a parameter called value in the function?
Thank you
-Salem Abdulkerim

1 Like


Yup, you’re on the right path.

pd.isnull(value) is equivalent to your current code value == 'NaN'. You can just replace the latter with the pd.isnull(value) and it should work.

And you need a parameter in your function but you can call it anything you want, not just value. The parameter is needed because apply_map will pass the element/value inside the column as an argument to the function update_vals. Without the parameter, they can’t pass anything, thus they cannot update your value.