Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.ma.MaskedArray.sum

MaskedArray.sum(axis=None,dtype=None,out=None,keepdims=<class numpy._globals._NoValue>)[source]

Return the sum of the array elements over the given axis.

Masked elements are set to 0 internally.

Refer tonumpy.sum for full documentation.

See also

ndarray.sum
corresponding function for ndarrays
numpy.sum
equivalent function

Examples

>>>x=np.ma.array([[1,2,3],[4,5,6],[7,8,9]],mask=[0]+[1,0]*4)>>>print(x)[[1 -- 3] [-- 5 --] [7 -- 9]]>>>print(x.sum())25>>>print(x.sum(axis=1))[4 5 16]>>>print(x.sum(axis=0))[8 5 12]>>>print(type(x.sum(axis=0,dtype=np.int64)[0]))<type 'numpy.int64'>

Previous topic

numpy.ma.MaskedArray.std

Next topic

numpy.ma.MaskedArray.trace

  • © Copyright 2008-2009, The Scipy community.
  • Last updated on Jun 10, 2017.
  • Created usingSphinx 1.5.3.

[8]ページ先頭

©2009-2025 Movatter.jp