Hi I have a variable 'age' in my data and i want to bin it in python and save it into a new variable. something like this"
data['new_age']= if data['age'] <= 16 then 'young'
if data['age'] > 16 & data['age'] <= 35 then 'adult'
else 'old' end
how can i do this with a pandas data frame?
Aucun commentaire:
Enregistrer un commentaire