c = 15
A = np.random.randn(M, N)
mask = np.zeros(M * N, dtype=bool)
mask[:c] = True
np.random.shuffle(mask)
mask = mask.reshape(M, N)
A[mask] = np.nan
Create sample numpy array with randomly placed NaNs