I am looking to create new columns in Python that use existing data from the CSV file to create groups in the new column.
eg. i have a sample data that has the age and i need to create a new column that groups ages into 'Young' 'Adult' and 'Elder'
My code looks like this at the moment as i am using Pandas -
import pandas as pd
insurance = pd.read_csv ('insurance.csv')
print(insurance)
insurance['age_cat']= if age < 24: return 'Young' elif x < 55: return 'Adult'
elif x >=56: return 'Elder' else: return 'other'
how would i do this?