Let’s say that we have the following list [1,2,3,4,5] and we want to repeat each element 3 times. Let’s see how we can do it in Python and numpy.
import numpy as np x = [1,2,3,4,5] # repeat each element 3 times np.repeat(x,3)
And we get:
array([1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5])