Numpy使用教程(一)
· 阅读需 5 分钟
术语
axis
对于二维数组,垂直为轴0,水平为轴1。许多操作可以沿着一个轴进行。
>>> x = np.arange(12).reshape(3,4)
>>> x
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> x.sum(axis=0)
array([12, 15, 18, 21])
>>> x.sum(axis=1)
array([ 6, 22, 38])