Premium problem150. Standardize Each Column Safely

Medium Locked

Given a 2-D float array, return an array of the same shape with each column standardised:

  • transform each column to (x - col_mean) / col_std, using the population std
  • a column with zero standard deviation comes back as all zeros, not NaN or inf

Input

[[1. 5.]
 [3. 5.]
 [5. 5.]]

Output

[[-1.22474487  0.        ]
 [ 0.          0.        ]
 [ 1.22474487  0.        ]]

Premium problem

This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.

Implement solve(...)