question 423 pandas Transformations · easy
The busiest departure hour
An airport plans staff around its busiest hour. Write busiest_hour(departures): given scheduled departure times like "2025-01-10 05:13", return the hour (0–23) with the most departures. On a tie, return the earliest of those hours; with no departures, return None.
Function
busiest_hour(departures)Returnsan int from 0 to 23, or
NoneExamples
callbusiest_hour(['2025-01-10 00:59', '2025-01-10 05:00', '2025-01-10 05:01', '2025-01-10 05:10', '2025-01-10 05:13', '2025-01-10 05:15', '2025-01-10 05:15', '2025-01-10 05:15', '2025-01-10 05:20', '2025-01-10 05:20', '2025-01-10 05:20', '2025-01-10 05:22'])returns5
callbusiest_hour(['2025-01-10 00:59', '2025-01-10 05:00', '2025-01-10 05:13'])returns5
callbusiest_hour([])returnsNone