a = np.array([[1, 1], [2, 2], [4, 4]])
ii = np.array([1, 1, 0])
ares = a.reshape((-1,), order='F')
col = np.tile(ii, (a.shape[1],))
row = np.tile([0, 1], (a.shape[0], 1)).reshape((-1,), order='F')
g = coo_matrix((ares, (col, row)), shape=(2, 2))
print(g.todense())
Использование numpy.bincount с весами массива