x = np.array([[10, 0, 10, 0], [1, 1, 0, 0], [9, 9, 9, 0], [0, 10, 1, 0]])
y = np.ma.masked_where(x == 0, x)
x
y
np.median(x, axis=0)
np.ma.median(y, axis=0).filled(0)
How can I ignore zeros when I take the median on columns of an array?