Days the Reservoir Rose
Problem
A water authority records the reservoir level once per day.
DataFrame: `reservoir_log` (from `reservoir_log.csv`)
| Column | Type |
|-------------|--------|
| reading_id | int |
| reading_day | object |
| level_cm | int |
`reading_id` is unique and there is at most one reading per day.
Write a function that returns the `reading_id` of every day whose `level_cm` is **strictly higher** than the level on the **immediately preceding calendar day** (yesterday). Return the column `reading_id`, in any order.
Input data
Example rows — the live problem includes the full dataset.
| reading_id | reading_day | level_cm |
|---|---|---|
| 1 | 2022-04-01 | 120 |
| 2 | 2022-04-02 | 135 |
| 3 | 2022-04-03 | 130 |
| 4 | 2022-04-04 | 150 |
Expected output
Your answer should return 2 rows with the columns reading_id.
Starter code (Pandas (Python))
import pandas as pd
def reservoir_rose(reservoir_log: pd.DataFrame) -> pd.DataFrame:
# Your code here
return reservoir_logSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock