numpy学习

numpy的最重要的一个结构是元素为同一类别的多维数组

numpy的维度叫axis,最外边的一个维度的axis为0,最外边第二个维度的axis为1

numpy的slice

numpy对每一个维度的选取是一个数字或者一个range

>>> a = arange(15).reshape(3, 5)
>>> a[1]
array([5, 6, 7, 8, 9])
>>> a[1, 2]
7
>>> a[1, 1:2]
array([6])
>>> a[1, 0:5:2]
array([5, 7, 9])
>>> 

numpy的函数中axis的理解

>>> a
array([[ 0,  1,  2,  3,  4],
       [ 5,  6,  7,  8,  9],
       [10, 11, 12, 13, 14]])
>>> a.sum(axis=0)
array([15, 18, 21, 24, 27])

指定axis=0,是指结果中的每一个元素是,其他axis不变而axis=0的维度遍历的结果

原文地址:https://www.cnblogs.com/jfwang/p/4281202.html