In [24]: a = np.arange(0,20,1).reshape(4,5)

In [25]: b = np.ma.masked_where(a%6==0, a)

In [26]: b
Out[26]:
masked_array(data =
 [[-- 1 2 3 4]
 [5 -- 7 8 9]
 [10 11 -- 13 14]
 [15 16 17 -- 19]],
             mask =
 [[ True False False False False]
 [False  True False False False]
 [False False  True False False]
 [False False False  True False]],
       fill_value = 999999)