I
idx0 = np.concatenate(I)
idx0
cut_idx = np.append(0, map(len, I))[:-1].cumsum()
cut_idx
X[:, (idx0)]
np.add.reduceat(X[:, (idx0)], cut_idx, axis=1)
Vectorize numpy indexing and apply a function to build a matrix