I think my code is correct, but I dont know why there is still an error showing. I changed age column to float date type already. I dont know it does not work. Thank you in advance!!!
Screen Link: https://app.dataquest.io/m/348/guided-project%3A-clean-and-analyze-employee-exit-surveys/11/next-steps
My Code:
def age_stage(col):
if 30 > col >= 20:
return '30~20'
elif 60 > col >= 50:
return '50~60'
elif 50 > col >= 40:
return '40~50'
elif 40 > col >= 30:
return '40~30'
elif pd.isnull(col):
return np.nan
else:
return 'over 60'
dis_true['age_stage']=dis_true['age'].apply(age_stage)
What actually happened:
TypeError: unorderable types: int() > str()