import numpy as np
print(np.repeat(10,5))
arr = np.arange(1,10).reshape(3,3)
print(‘Original array: \n’,arr)
print(‘Array after repeat 3 times along rows: \n’,np.repeat(arr,3,axis=1))
print(‘Array after repeat 3 times along columns: \n’,np.repeat(arr,3,axis=0))
Output
[10 10 10 10 10]
Original array:
[[1 2 3]
[4 5 6]
[7 8 9]]
Array after repeat 3 times along rows:
[[1 1 1 2 2 2 3 3 3]
[4 4 4 5 5 5 6 6 6]
[7 7 7 8 8 8 9 9 9]]
Array after repeat 3 times along columns:
[[1 2 3]
[1 2 3]
[1 2 3]
[4 5 6]
[4 5 6]
[4 5 6]
[7 8 9]
[7 8 9]
[7 8 9]]