AnalystPath

Stations With a Warming Streak

PandasHardSenior level~10 min

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_log
reading_idstation_idread_onhigh_celsius
11012023-06-0120
21012023-06-0223
31012023-06-0327
41012023-06-0430
52022023-06-0118

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_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