I have a masked array. I can get back the data via array.data, but this does not filter the data trough the mask.
How can I can get the data, but in the place where there is mask to get zero.
Here is what I got so far :
ary.data * (~ary.mask).astype(byte)
use numpy.ma.filled()
:
import numpy as np
m = np.ma.masked_greater(np.random.rand(10), 0.5)
print np.ma.filled(m, 0)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.