I'm trying to do the following, just misunderstand where I'm wrong:
In: import numpy as np
In: a = np.array([[0., 1., 0.],
[1., 2., 0.],
[0., 3., 0.]])
In: for i in range(a.shape[1]):
a[:, i] = np.ma.masked_where(~a[:, i].any(), a[:, i])
Out: array([[0., 1., --],
[1., 2., --],
[0., 3., --]])
The point here is to mask only the third column because it's completely zeros, and leave the first column zeros unmasked
---is not a valid Python identifier.--is what NumPy will output when a value is masked.