def FindAinB(A, B):
    assert A.shape[1
        ] % 10 == 0, 'Number of columns in A is not a multiple of 10'
rng = np.arange(A.shape[1])
A.columns = pd.MultiIndex.from_product([list(range(A.shape[1] / 10)), list(range(10))])
twos = 2 ** np.arange(10)
return A.stack(0).dot(twos).unstack()
Comparing rows of two pandas dataframes?