np vstack multiple arrays

Solutions on MaxInterview for np vstack multiple arrays by the best coders in the world

showing results for - "np vstack multiple arrays"
Rafael
08 Jun 2019
1>>> import numpy as np
2>>> a = ([1,2,3,4,5])
3>>> b = ([2,3,4,5,6])
4>>> c = ([3,4,5,6,7])
5
6>>> np.array([a, b, c])
7array([[1, 2, 3, 4, 5],
8       [2, 3, 4, 5, 6],
9       [3, 4, 5, 6, 7]])
10
11>>> np.stack([a, b, c], axis=0)
12array([[1, 2, 3, 4, 5],
13       [2, 3, 4, 5, 6],
14       [3, 4, 5, 6, 7]])
15
16>>> np.stack([a, b, c], axis=1)  # not what you want, this is only to show what is possible
17array([[1, 2, 3],
18       [2, 3, 4],
19       [3, 4, 5],
20       [4, 5, 6],
21       [5, 6, 7]])