How to transform each element of a numpy array into an array in Python

1 Answer

0 votes
import numpy as np

arr = np.array([[1,2,3],[4,5,6]])

result = np.dstack((arr, arr, arr))

print(result)


'''
run:

[[[1 1 1]
  [2 2 2]
  [3 3 3]]

 [[4 4 4]
  [5 5 5]
  [6 6 6]]]

'''

 



answered Jun 30, 2023 by avibootz
...