December 2017
Intermediate to advanced
386 pages
10h 42m
English
This recipe applies when we know in advance the position of an array that should be masked. The following code illustrates this situation:
x = np.array([1.0, 3.2, -2.1, 4.3, 5.4])xm = ma.masked_array(x, [0, 0, 1, 0, 0])
In the preceding code, we first define a one-dimensional array x with five items. Then, in the second line, we create the masked array xm, applying the mask [0,0,1,0,0] to the array x. This has the effect of masking the third entry of the array. By printing repr(xm), we can glimpse how the array is represented, as shown in the following output:
masked_array(data = [1.0 3.2 -- 4.3 5.4], mask = [False False True False False], fill_value = 1e+20)
There are these important points to ...
Read now
Unlock full access