numpy.ma.masked_all#
- ma.masked_all(shape, dtype=<class 'float'>)[來源]#
所有元素皆被遮罩的空遮罩陣列。
傳回指定形狀和 dtype 的空遮罩陣列,其中所有資料皆被遮罩。
- 參數:
- shape整數或整數元組
所需 MaskedArray 的形狀,例如
(2, 3)
或2
。- dtypedtype,選用
輸出的資料類型。
- 傳回值:
- aMaskedArray
所有資料皆被遮罩的遮罩陣列。
另請參閱
masked_all_like
以現有陣列為模型建立的空遮罩陣列。
註解
與其他遮罩陣列建立函式 (例如
numpy.ma.zeros
、numpy.ma.ones
、numpy.ma.full) 不同,masked_all
不會初始化陣列的值,因此可能會稍微快一點。但是,新配置的陣列中儲存的值是任意的。為了獲得可重現的行為,請務必在讀取之前設定陣列的每個元素。範例
>>> import numpy as np >>> np.ma.masked_all((3, 3)) masked_array( data=[[--, --, --], [--, --, --], [--, --, --]], mask=[[ True, True, True], [ True, True, True], [ True, True, True]], fill_value=1e+20, dtype=float64)
dtype
參數定義了底層資料類型。>>> a = np.ma.masked_all((3, 3)) >>> a.dtype dtype('float64') >>> a = np.ma.masked_all((3, 3), dtype=np.int32) >>> a.dtype dtype('int32')