Mistake: a NaN means the code is broken
“Standardizing produced NaNs, so there is a bug in the formula.”
D = np.array([[0., 1., 5.], [0., 3., 9.], [0., 2., 7.]])
std = D.std(axis=0)
assert std[0] == 0.0
Z = (D - D.mean(axis=0)) / std
assert np.isnan(Z[:, 0]).all()
assert np.isfinite(Z[:, 1:]).all()
Column 0 never varies, so the formula divided by zero; every other column is finite. The code is correct and it reported a property of the data. A zero-variance feature is a finding, not a bug — drop it or keep it, but say which.