One customer who spent a hundred times the median will dominate any average you compute and any model you fit. Winsorising, which means clipping the extremes to a percentile instead of deleting the rows, is the usual first response.
Write clip_to_percentiles(x, lower, upper).
x is a 1D array. lower and upper are percentiles between 0 and 100. Compute those two percentiles of x, then return a copy of x with every value below the lower one raised to it, and every value above the upper one lowered to it.
You have read the opening. The rest is free with a Bezen account, and no card is needed.
Behind the sign-in