AnalystPath

Idle Forklift Shifts

PandasHardSenior level~10 min

Problem

One CSV file, `forklift_log.csv`, tracks every forklift action (`entry_id`, `vehicle_id`, `logged_at` timestamp, `action_kind` such as 'startup', 'travel', 'lift', or 'load', `shift_code`, and an optional `payload_kg`). Operations wants to flag idle shifts that look busy but accomplish little. A shift is idle when ALL hold: it spans more than 30 minutes from its first to its last action; it has at least 5 'travel' actions; the ratio of 'lift' actions to 'travel' actions is below 0.2; and it recorded no 'load' actions at all. Return each idle shift's `shift_code` and its number of travel actions as `travel_count`, ordered by `travel_count` descending, then by `shift_code` ascending.

Input data

Example rows — the live problem includes the full dataset.

forklift_log
entry_idvehicle_idlogged_ataction_kindshift_codepayload_kg
172024-02-01 08:00:00startupF001
272024-02-01 08:05:00travelF001
372024-02-01 08:12:00travelF001
472024-02-01 08:20:00travelF001
572024-02-01 08:28:00travelF001

Expected output

Your answer should return 2 rows with the columns shift_code, travel_count.

Starter code (Pandas (Python))

import pandas as pd

def find_idle_shifts(forklift_log) -> pd.DataFrame:
    # Your code here
    return forklift_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