#横向
y=[1,2,3]
y = np.expand_dims(y, axis=0)
y
输出结果:
array([[1, 2, 3]])
# 纵向
y=[1,2,3]
y = np.expand_dims(y, axis=1)
y
输出结果:
array([[1],
[2],
[3]])
2. concatenate 拼接
y=("a","b","c")
Y = np.concatenate([y] * 32, axis=0)
Y
输出结果 欢迎分享,转载请注明来源:内存溢出
array([‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’,
‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’,
‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’,
‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’,
‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’,
‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’,
‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’,
‘b’, ‘c’, ‘a’, ‘b’, ‘c’], dtype=‘
评论列表(0条)