n = len(a)
ngroup = 10
counts = np.ones(ngroup, int) * (n // ngroup)
counts[:n % ngroup] += 1
q = np.r_[0, np.cumsum(counts / float(n))]
q[-1] = 1.0
r2 = pd.qcut(a, q)
np.bincount(r2.labels)
Python Pandas qcut behavior with # of observations not divisible by # of bins