I have an array A = np.array([1.43, 5.12, 2.67])
I want to make a multidimensional array named B from array A using np.repeat like this
B =np.repeat(A, 4)
and the result show like this:
B = [1.43, 1.43, 1.43, 1.43, 5.12, 5.12, 5.12, 5.12, 2.67, 2.67, 2.67, 2.67)
But i want the result shown like this:
B = ([1. 43, 1.43, 1.43, 1.43],
[5.12, 5.12, 5.12, 5.12],
[2.67, 2.67, 2.67, 2.67])
What should I do to get the result like that?
np.tile(A, (3,1)).Tornp.repeat(A, 3).reshape(3,-1)np.broadcast_to(A[:, None], (A.shape[0], 4))Aa (3,1) shape, you can apply repeat to the last aixs:np.repeat(A,4, axis=1)