mask = np.arange(lens.max()) < lens[:, (None)]
out = np.zeros(mask.shape, dtype=data.dtype)
out[mask] = np.concatenate(data)
return out
Numpy: Fix array with rows of different lengths by filling the empty elements with zeros