All problems
Standardize Columns
Problem
Standardize each column of data to zero mean and unit sample variance (denominator n - 1).
If a column has zero variance, output 0.0 for every entry in that column. Return a list of rows of floats.
Hint
Divide the centered values by the sample standard deviation.
Test cases
case 1
in: [[[1,2],[3,4],[5,6]]]
expected: [[-1,-1],[0,0],[1,1]]
case 2
in: [[[1,10],[2,20],[3,30]]]
expected: [[-1,-1],[0,0],[1,1]]
case 3
in: [[[5,5],[5,5]]]
expected: [[0,0],[0,0]]
case 4
in: [[[1,0],[0,1]]]
expected: [[0.7071067811865475,-0.7071067811865475],[-0.7071067811865475,0.7071067811865475]]
Starter codePython
def standardize_columns(data):
# Your code here
pass4 test cases · run your code against them in the editor