Stations With a Warming Streak
Problem
You are given a DataFrame `reading_log` (from `reading_log.csv`) with columns `reading_id`, `station_id`, `read_on` (a date), and `high_celsius` (that day's high temperature).
A warming streak is a run of consecutive calendar days at one station where each day's high is strictly greater than the previous day's. Report every streak that spans at least three consecutive readings (the original counts at least two day-over-day increases). For each qualifying streak return `station_id`, `streak_start` (the first day of the streak, as YYYY-MM-DD), and `streak_end` (the last day of the streak, as YYYY-MM-DD). Order does not matter.
Input data
Example rows — the live problem includes the full dataset.
| reading_id | station_id | read_on | high_celsius |
|---|---|---|---|
| 1 | 101 | 2023-06-01 | 20 |
| 2 | 101 | 2023-06-02 | 23 |
| 3 | 101 | 2023-06-03 | 27 |
| 4 | 101 | 2023-06-04 | 30 |
| 5 | 202 | 2023-06-01 | 18 |
Expected output
Your answer should return 1 row with the columns station_id, streak_start, streak_end.
Starter code (Pandas (Python))
import pandas as pd
def stations_with_a_warming_streak(reading_log) -> pd.DataFrame:
# Your code here
return reading_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