runtime
407 / 500
question 407 NumPy Foundations · medium

Standardise each station's readings

To compare how unusual each day was at stations with very different climates, convert every reading to a z-score within its own row: (reading − that row's mean) / that row's standard deviation. A row whose readings are all the same has no spread; its z-scores are all 0.

Functionstandardize_rows(grid)
grida list of rows (stations), each a list of readings
Returnsa list of rows of floats, same shape as grid
Rulesuse the population standard deviation (NumPy's default std)
Examples
callstandardize_rows([[1, 2, 3], [10, 20, 30]])returns[[-1.224744871391589, 0, 1.224744871391589], [-1.224744871391589, 0, 1.224744871391589]]
callstandardize_rows([[2, 4]])returns[[-1, 1]]
callstandardize_rows([[5, 5, 5], [0, 10, 5]])returns[[0, 0, 0], [-1.224744871391589, 1.224744871391589, 0]]

Loading your progress…

Standardise each station's readings — Python practice · Runtime