Python axis的含义


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]])

---------------------
作者:Rango_lhl
来源:CSDN
原文:https://blog.csdn.net/rango_lhl/article/details/50542887
版权声明:本文为博主原创文章,转载请附上博文链接!


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM