Carry the Last Value
readings has columns hour and temp. Some temperatures are missing (None). Replace each missing value with the most recent earlier temperature. The first row is never missing. Return the temperatures as a list.
Example 1
readings {"hour":[1,2,3,4],"temp":[10.0,null,null,13.0]}
returns [10.0,10.0,10.0,13.0]
The two gaps take the value 10.0.
Constraints
- The first temperature is present
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More pandas problems
- Colour TallyBeginner
- Column StatisticsBeginner
- Column TotalBeginner
- Correlation of ColumnsBeginner
- Count Missing ValuesBeginner
- Count Repeated RowsBeginner
- Count Unique CitiesBeginner
- Count in RangeBeginner