[Python] numpy.sum

import numpy as np

#Syntax:
numpy.sum(a, axis=None, dtype=None, out=None, keepdims=)

  

计算中所有元素的值

 

Example:

a = [1,2]
print np.sum(a)
#3

a = np.matrix('1,2;3,4')
print np.sum(a)
#10

print np.sum(a, axis=0)
#[4, 6]

print np.sum(a, axis = 1)
#[3, 7]

  

转载于:https://www.cnblogs.com/KennyRom/p/6607645.html

你可能感兴趣的:([Python] numpy.sum)