rng = np.arange(A.shape[1])
A.columns = pd.MultiIndex.from_product([list(range(A.shape[1] / 10)), list(range(10))])
return (A.stack(0) << np.arange(10)).sum(1).unstack()
Comparing rows of two pandas dataframes?