df = pd.DataFrame(invs)
result = df.reset_index().groupby(0).index.apply(list).to_frame()
result['sample'] = [list(x) for x in a[inds]]
How to determine row equality across several rows in a fully vectorized way?