本文簡要介紹 python 語言中 numpy.ma.sum
的用法。
用法:
ma.sum(self, axis=None, dtype=None, out=None, keepdims=<no value>) = <numpy.ma.core._frommethod object>
返回給定軸上數組元素的總和。
被屏蔽的元素在內部設置為 0。
有關完整文檔,請參閱
numpy.sum
。例子:
>>> x = np.ma.array([[1,2,3],[4,5,6],[7,8,9]], mask=[0] + [1,0]*4) >>> x masked_array( data=[[1, --, 3], [--, 5, --], [7, --, 9]], mask=[[False, True, False], [ True, False, True], [False, True, False]], fill_value=999999) >>> x.sum() 25 >>> x.sum(axis=1) masked_array(data=[4, 5, 16], mask=[False, False, False], fill_value=999999) >>> x.sum(axis=0) masked_array(data=[8, 5, 12], mask=[False, False, False], fill_value=999999) >>> print(type(x.sum(axis=0, dtype=np.int64)[0])) <class 'numpy.int64'>
相關用法
- Python numpy ma.set_fill_value用法及代碼示例
- Python numpy ma.sort用法及代碼示例
- Python numpy ma.stack用法及代碼示例
- Python numpy ma.size用法及代碼示例
- Python numpy ma.shape用法及代碼示例
- Python numpy ma.squeeze用法及代碼示例
- Python numpy ma.indices用法及代碼示例
- Python numpy ma.zeros用法及代碼示例
- Python numpy ma.diff用法及代碼示例
- Python numpy ma.mask_rowcols用法及代碼示例
- Python numpy ma.where用法及代碼示例
- Python numpy ma.zeros_like用法及代碼示例
- Python numpy ma.notmasked_contiguous用法及代碼示例
- Python numpy ma.concatenate用法及代碼示例
- Python numpy ma.apply_along_axis用法及代碼示例
- Python numpy ma.compress_rowcols用法及代碼示例
- Python numpy ma.vstack用法及代碼示例
- Python numpy ma.atleast_3d用法及代碼示例
- Python numpy ma.count用法及代碼示例
- Python numpy ma.fix_invalid用法及代碼示例
- Python numpy ma.mean用法及代碼示例
- Python numpy ma.argmax用法及代碼示例
- Python numpy ma.empty_like用法及代碼示例
- Python numpy ma.hstack用法及代碼示例
- Python numpy ma.isMA用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.ma.sum。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。