本文簡要介紹 python 語言中 numpy.ma.ones
的用法。
用法:
ma.ones(shape, dtype=None, order='C') = <numpy.ma.core._convert2ma object>
返回一個給定形狀和類型的新數組,用一個填充。
- shape: int 或整數序列
新數組的形狀,例如
(2, 3)
或2
。- dtype: 數據類型,可選
數組所需的數據類型,例如
numpy.int8
。默認為numpy.float64
。- order: {‘C’, ‘F’},可選,默認:C
是否在內存中以行優先(C 風格)或列優先(Fortran-style)順序存儲多維數據。
- like: array_like
允許創建非 NumPy 數組的引用對象。如果作為
like
傳入的類似數組支持__array_function__
協議,則結果將由它定義。在這種情況下,它確保創建一個與通過此參數傳入的數組對象兼容的數組對象。
- out: MaskedArray
具有給定形狀、dtype 和順序的數組。
參數:
返回:
例子:
>>> np.ones(5) array([1., 1., 1., 1., 1.])
>>> np.ones((5,), dtype=int) array([1, 1, 1, 1, 1])
>>> np.ones((2, 1)) array([[1.], [1.]])
>>> s = (2,2) >>> np.ones(s) array([[1., 1.], [1., 1.]])
相關用法
- Python numpy ma.ones_like用法及代碼示例
- Python numpy ma.outerproduct用法及代碼示例
- Python numpy ma.outer用法及代碼示例
- 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用法及代碼示例
- Python numpy ma.argmin用法及代碼示例
- Python numpy ma.asarray用法及代碼示例
- Python numpy ma.set_fill_value用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.ma.ones。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。