FunctionRacerProblemsRace

Fill Missing

EasyNumPyPython

A broken sensor wrote -1 whenever it failed to measure. Return a new array in which every -1 is replaced by the average of the readings that are not -1. At least one reading is valid.

Example 1

readings [4,-1,8]
returns [4.0,6.0,8.0]

The valid readings average (4 + 8) / 2 = 6, so the result is [4, 6, 8].

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