Hi @universalastrostuden,
When I ran your notebook file, I received this error:
tafe_resignations["dissatisfied"].value_counts()
KeyError: 'dissatisfied'
This can be fixed by changing this line
tafe_factors = tafe_resignations[factors].applymap(update_vals)
to
tafe_resignations['dissatisfied'] = tafe_resignations[['Contributing Factors. Dissatisfaction', 'Contributing Factors. Job Dissatisfaction']].applymap(update_vals).any(1, skipna=False)
Also
if val == 'NaN':
return np.nan
in update_vals()
should be changed to
if pd.isnull(val):
return nan
Now the values will be correct, but NaN value counts won’t be displayed unless you add dropna=False
argument:
tafe_resignations["dissatisfied"].value_counts(dropna=False)
When I continued execution, I received another error:
pv_combined = pd.pivot_table(combined_updated, values=['dissatisfied'], index="service_cat", margins=True)
KeyError: 'service_cat'
To fix it, you have to change this line
service_cat = years_of_service.apply(whichcat)
into
combined_updated['service_cat'] = years_of_service.apply(whichcat)
The next error is the one you mentioned in your post
pv_combined.plot(kind="bar",xlim=(0,10),title="Dissatisfaction by Service Category",legend=False)
TypeError: Empty 'DataFrame': no numeric data to plot
Here the error is very clear that the DataFrame doesn’t have any numeric data to plot:
dissatisfied
service_cat
Established True
Experienced True
New True
Veteran True
All True
All of the values are True
. I would recommend you to go through the solution page and compare it with the code you have used. This will help you identify why you are getting the above values.
Best,
Sahil