AnalystPath

Days the Reservoir Rose

PandasEasyJunior level~10 min

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.

reservoir_log
reading_idreading_daylevel_cm
12022-04-01120
22022-04-02135
32022-04-03130
42022-04-04150

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_log

Solve 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

Related Pandas questions