📜  numpy 如何 dropzero - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:13.230000             🧑  作者: Mango

代码示例1
X = np.random.randn(1e3, 5)
X[np.abs(X)< .1]= 0 # some zeros
X = np.ma.masked_equal(X,0)
plt.boxplot(X) #masked values are not plotted

#other functionalities of masked arrays
X.compressed() # get normal array with masked values removed
X.mask # get a boolean array of the mask
X.mean() # it automatically discards masked values