How to join a sequence of arrays in Python

2 Answers

0 votes
import numpy as np

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

result = np.stack((a, b))

print(result)


'''
run:

[[1 2 3]
 [4 5 6]]

'''

 



answered Mar 22 by avibootz
0 votes
import numpy as np

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

result = np.stack((a, b), axis = -1)

print(result)



'''
run:

[[1 4]
 [2 5]
 [3 6]]

'''

 



answered Mar 22 by avibootz
...