AnalystPath

Repeat Gate Entries Within a Day

PandasEasyJunior level~10 min

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.

gate_events
vehicle_identered_atlane
32021-01-06 03:30:46north
32021-01-06 03:37:45north
72021-06-12 11:57:29south
72021-06-13 11:57:30south
22021-01-22 00:00:00east

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_events

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