repeat array along new axis

Solutions on MaxInterview for repeat array along new axis by the best coders in the world

showing results for - "repeat array along new axis"
Sara Sofía
24 Apr 2017
1a = np.array([[1, 2], [1, 2]])
2# indexing with np.newaxis inserts a new 3rd dimension, 
3# which we then repeat the array along
4b = np.repeat(a[:, :, np.newaxis], 3, axis=2)
5print(b.shape)
6# (2, 2, 3)
similar questions
queries leading to this page
repeat array along new axis