All problems
Center Columns
Problem
Center each column of data by subtracting its column mean, the effect of multiplying by the centering matrix.
Return the centered data as a list of rows of floats.
Hint
Every centered column sums to zero.
Test cases
case 1
in: [[[1,2],[3,4],[5,6]]]
expected: [[-2,-2],[0,0],[2,2]]
case 2
in: [[[1,2],[2,4]]]
expected: [[-0.5,-1],[0.5,1]]
case 3
in: [[[5,5],[5,5]]]
expected: [[0,0],[0,0]]
case 4
in: [[[1,3,5]]]
expected: [[0,0,0]]
Starter codePython
def center_columns(data):
# Your code here
pass4 test cases · run your code against them in the editor