AnalystPath

Busiest Scan Hour per Warehouse Zone

PandasMediumMid level~10 min

Problem

DataFrame `scan_event` has columns `scanner_id`, `parcel_id`, `scanned_at` (a timestamp), and `zone`. For each zone, find the hour of day (0..23) with the most scans. Use RANK-style ties: if several hours share the top count within a zone, return all of them.

Return columns `zone`, `busy_hour`, `scan_count`, sorted by `busy_hour` descending then `zone` descending.

Input data

Example rows — the live problem includes the full dataset.

scan_event
scanner_idparcel_idscanned_atzone
11002024-04-01 09:05:00Inbound
11012024-04-01 09:40:00Inbound
21022024-04-01 14:10:00Inbound
31032024-04-01 14:20:00Packing
31042024-04-01 14:55:00Packing

Expected output

Your answer should return 2 rows with the columns zone, busy_hour, scan_count.

Starter code (Pandas (Python))

import pandas as pd

def busiest_scan_hour(scan_event) -> pd.DataFrame:
    # Your code here
    return scan_event

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