MaskedArray.compress(condition,axis=None,out=None)[source]¶Returna where condition isTrue.
If condition is aMaskedArray, missing values are consideredasFalse.
| Parameters: | condition : var
axis : {None, int}, optional
out : {None, ndarray}, optional
|
|---|---|
| Returns: | result : MaskedArray
|
Notes
Please note the difference withcompressed !The output ofcompress has a mask, the output ofcompressed does not.
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]]>>>x.compress([1,0,1])masked_array(data = [1 3], mask = [False False], fill_value=999999)
>>>x.compress([1,0,1],axis=1)masked_array(data = [[1 3] [-- --] [7 9]], mask = [[False False] [ True True] [False False]], fill_value=999999)