I have a column with the ages of customers.I want another column to be determined on these ages.Suppose the other column in a custom list and has values a,b,c,d,e and I want to have one of a,b and c for every customer of age group 16-60.What formula can be used?
What you are looking for is binning. Since you have not provided the tech stack you are working on, I’ll provide an example with pandas DataFrame.
For age, you would have to define the bins=[10,25,50,90] and groups = [a,b,c]
Now, to create a new column in the DataFrame with this binned values:
df[‘new_categories’] = pd.cut(df[‘Age’],bins=bins, labels=groups])
This basically groups the age in the bins that you have provided, say (10-25] and marks it as ‘a’ in a new column called ‘new_categories’.
Hope this helps.