detect_ghost_vehicles¶
detect_ghost_vehicles
¶
detect_ghost_vehicles(vehicle_panel: DataFrame, *, idle_days: float = 14.0, move_threshold_m: float = 50.0) -> DataFrame
Flag immobile ("ghost") vehicles from a longitudinal vehicle panel.
A unit advertised at (essentially) the same coordinates for a long stretch is almost
certainly lost, broken, or abandoned, yet it inflates availability. Given a panel of
free-floating vehicle snapshots over time, this measures each vehicle's displacement from
its first observed position and flags those that never moved beyond move_threshold_m
across a span of at least idle_days.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vehicle_panel
|
DataFrame
|
Long frame of vehicle snapshots with |
required |
idle_days
|
float
|
Minimum observed span (first→last sighting) for a vehicle to qualify. |
14
|
move_threshold_m
|
float
|
Maximum great-circle displacement (metres) from the first position to count as immobile (absorbs GPS jitter). |
50
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Indexed by |
See Also
vehicle_idle_time : The fleet-wide idle share over time.
reconcile_fleet_state : The deduplicated fleet tally.
Examples:
>>> import pandas as pd
>>> panel = pd.DataFrame({
... "system_id": "s", "vehicle_id": "v1",
... "lat": [48.85, 48.85], "lon": [2.35, 2.35],
... "fetched_at": pd.to_datetime(["2026-01-01T00:00Z", "2026-01-20T00:00Z"]),
... })
>>> bool(detect_ghost_vehicles(panel)["is_ghost"].iloc[0])
True
Source code in src/gbfs_toolkit/analytics/fleet.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |