1. 程式人生 > >numpy常用操作

numpy常用操作

水平合併陣列

import numpy as np

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

c = [a,['a','b','c']]
d = [b,['d','e','f']]
np.hstack((c,d))

#array([['1', '2', '3', '4', '5', '6'],
#       ['a', 'b', 'c', 'd', 'e', 'f']], dtype='<U11')