copy array along axis numpy

Solutions on MaxInterview for copy array along axis numpy by the best coders in the world

showing results for - "copy array along axis numpy"
Tom
02 Oct 2018
1a = np.array([[1, 2], [1, 2]])
2
3# indexing with np.newaxis inserts a new 3rd dimension, which we then repeat the
4# array along, (you can achieve the same effect by indexing with None, see below)
5b = np.repeat(a[:, :, np.newaxis], 3, axis=2)
6
7print(b[:, :, 2])
8# [[1 2]
9#  [1 2]]
10
similar questions
queries leading to this page
copy array along axis numpy