I'm quite new with pandas and need a bit help. I have a column with ages and need to make groups of these: Young people: age≤30 Middle-aged people: 30<age≤60 Old people:60<age Here is the code, but it gives me an error:
def get_num_people_by_age_category(dataframe):
young, middle_aged, old = (0, 0, 0)
dataframe["age"] = pd.cut(x=dataframe['age'], bins=[30,31,60,61], labels=["young","middle_aged","old"])
return young, middle_aged, old
ages = get_num_people_by_age_category(dataframe)
print(dataframe)