before we proceedlet' examine how the distribution of customer recency looks for our data (see figure - customer_history_df recency mu np mean(customer_history_df recencysigma math sqrt(np var(customer_history_df recency)nbinspatches plt hist( facecolor='green'alpha= add 'best fitline mlab normpdfbinsmusigmal plt plot(binsy' --'linewidth= plt xlabel('recency in days'plt ylabel('number of transactions'plt title( '$\mathrm{histogramofsalesrecency}$'plt grid(truefigure - distribution of sales recency the histogram in figure - tells us that we have skewed distribution of sales recency with much higher number of frequent transactions and fairly uniform number of less recent transactions frequency and monetary value using similar methodswe can create frequency and monetary value variable for our dataset we will create these variables separately and then merge all the dataframes to arrive at the customer value dataset we will perform our clustering-based customer segmentation on this dataframe the following snippet will create both these variables and the final merged dataframe