Repeat Gate Entries Within a Day
Problem
A parking garage logs every time a vehicle passes through the entry gate.
You are given one DataFrame `gate_events`:
| Column | Type |
|------------|----------|
| vehicle_id | int |
| entered_at | datetime |
| lane | str |
`(vehicle_id, entered_at)` is unique. Each row records a single gate entry by a vehicle.
Find the `vehicle_id` of every vehicle that entered the gate **at least twice within a 24-hour window**. Two entries that are exactly 24 hours apart still count as inside the window.
Return a DataFrame with a single `vehicle_id` column, in any order.
Input data
Example rows — the live problem includes the full dataset.
| vehicle_id | entered_at | lane |
|---|---|---|
| 3 | 2021-01-06 03:30:46 | north |
| 3 | 2021-01-06 03:37:45 | north |
| 7 | 2021-06-12 11:57:29 | south |
| 7 | 2021-06-13 11:57:30 | south |
| 2 | 2021-01-22 00:00:00 | east |
Expected output
Your answer should return 3 rows with the columns vehicle_id.
Starter code (Pandas (Python))
import pandas as pd
def repeat_gate_entries(gate_events: pd.DataFrame) -> pd.DataFrame:
# Your code here
return gate_eventsSolve 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