FunctionRacerProblemsRace

Average of Chosen Rows

EasyNumPyPython

Take only the rows of grid whose row numbers are listed in chosen (in that order, and a row number may repeat), then return a list with the average of each column over those rows. Hint: grid[chosen] picks rows.

Example 1

grid [[1,2],[3,4],[5,6]]
chosen [0,2]
returns [3.0,4.0]

Rows 0 and 2 are [1, 2] and [5, 6], averaging [3.0, 4.0].

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems