Sep 15, 2023
Excellent article! I would add that for binning, pd.cut works very well and can be used with lists, arrays, series, and dataframes, e.g.:
ages = [10,29,30,50,60,70,90]
agebins = [0,29,60,np.inf]
agelabels = ['young','middle-aged','old']
pd.cut( ages, bins=agebins, labels=agelabels,right=False )