08-numpy-笔记-sum

求和:

axis = 0 按列求和

axis = 1 按行求和

 

>>> import numpy as np
>>> a = np.mat([[1,2,3],[4,5,6]])
>>> a
matrix([[1, 2, 3],
        [4, 5, 6]])
>>> a.sum(axis = 0)
matrix([[5, 7, 9]])
>>> a.sum(axis = 1)
matrix([[ 6],
        [15]])
>>> a.sum()
21

  

 

posted @ 2018-04-23 11:51  路边的十元钱硬币  阅读(165)  评论(0编辑  收藏  举报