Python中的axis=0,axis=1

axis=0表述列
axis=1表述行

如下面例子:

In [52]: arr=np.arange(12).reshape((3,4))
In [53]:arr
Out[53]:
array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]])
In [54]:np.concatenate([arr,arr],axis=0)
Out[54]:
array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]])
In [55]:np.concatenate([arr,arr],axis=1)
Out[55]:
array([[ 0, 1, 2, 3, 0, 1, 2, 3], [ 4, 5, 6, 7, 4, 5, 6, 7], [ 8, 9, 10, 11, 8, 9, 10, 11]])

Python中的axis=0,axis=1_第1张图片
Python中的axis=0,axis=1_第2张图片

你可能感兴趣的:(python)