np.array([' '.join( np.repeat(x, z)) for z in y ])
repeat
handles the repetition part for row of y
nicely. The rest is just iteration on the rows. We don't need the generality of apply_along_axis
here.
The repeat could be applied to all of y
without loop with
n=y.shape[0]
X = np.repeat([x]*n, y.flat).reshape(n, -1)
But the join still has to be done iteratively.
[' '.join(I) for I in X]