My dataframe (tdf) has a column called Age that contains a list of ages between 0 and 86. I want to create a new column in the dataframe called age_groups and populate it with a label based on that rows Age value. The code I'm using to do that is:
labels=['Child', 'Teen', 'Adult', 'Retired']
tdf['age_group']=pd.cut(tdf['Age'], bins=[0, 12, 18, 65, 86],labels=labels)
However this throws up a SettingWithCopyWarning and I'm wondering how do I modify it to avoid that (I do not want to just suppress the warning)?