It seems to me that you are looking for the scipy.stats.scoreatpercentile function.