def rank(s,q): top_quantile=s[q].quantile(0.75) down_quantile=s[q].quantile(0.25) med=s[q].median() quartile=[] if q=='recency': for i in s[q]: if i<=dowm_qu...