A weather station stores one row per hour: [temperature, humidity, wind speed, ...]. Every row has the same number of features, and position j always means the same measurement. Before using the data, an analyst wants to know the smallest and the largest value of each feature (each column), because a feature that is the same in every row tells a model nothing.
Write feature_ranges(rows) that returns a list with one pair (low, high) per feature, in column order, where low is the smallest and high the largest value in that column.
Examples
Input: rows = [[12, 80, 5], [15, 72, 5], [9, 91, 5]]
Output: [(9, 15), (72, 91), (5, 5)]
Explanation: column 0 holds 12, 15, 9; column 1 holds 80, 72, 91; column 2 is always 5,
so the third feature carries no information about the hours.
Input: rows = [[-3.5, 2]]
Output: [(-3.5, -3.5), (2, 2)]
Constraints
1 <= len(rows) <= 10**4, and every row has the same lengthdwith1 <= d <= 20- values are ints or floats; return them unchanged (no rounding)
- a list
[low, high]is accepted in place of a tuple
Goals
- Read a dataset column by column instead of row by row
- Keep a running minimum and maximum for every feature at once
- Spot a feature that never changes and so carries no information