new column with age interval pandas

df_ages['age_bins'] = pd.cut(x=df_ages['age'], bins=[20, 29, 39, 49])

Here is what the above code is Doing:
1. We’re creating a new column in our df_ages dataframe called ‘age_bins’.
2. We’re using the pd.cut() function to cut the age column into bins.
3. We’re using the bins=[20, 29, 39, 49] argument to specify the bins.