Feed-intrinsic free-floating tagging from GBFS v3 is_virtual_station.
A station flagged is_virtual_station = true is a virtual free-floating
anchor, not a physical dock; this sets its station_type to
"free_floating" directly from the feed, the spec-defined signal that the
over-capacity ratio only approximates. If the field is absent the frame is
returned unchanged. Returns a copy; the input is not mutated.
See Also
classify_from_vehicle_types : The sibling car-sharing tag from form_factor.
reclassify_overcapacity : The ratio-based fallback when the spec signal is absent.
audit_static : The A1-A7 audit whose A3 consumes the free_floating label.
Examples:
>>> import pandas as pd
>>> info = pd.DataFrame({
... "station_type": ["docked_bike", "docked_bike"],
... "is_virtual_station": [False, True],
... })
>>> classify_from_virtual_station(info)["station_type"].tolist()
['docked_bike', 'free_floating']
Source code in src/gbfs_toolkit/audit/static.py
| def classify_from_virtual_station(info: pd.DataFrame) -> pd.DataFrame:
"""Feed-intrinsic free-floating tagging from GBFS v3 ``is_virtual_station``.
A station flagged ``is_virtual_station = true`` is a virtual free-floating
anchor, not a physical dock; this sets its ``station_type`` to
``"free_floating"`` directly from the feed, the spec-defined signal that the
over-capacity ratio only approximates. If the field is absent the frame is
returned unchanged. Returns a copy; the input is not mutated.
See Also
--------
[`classify_from_vehicle_types`][gbfs_toolkit.classify_from_vehicle_types] : The sibling car-sharing tag from ``form_factor``.
[`reclassify_overcapacity`][gbfs_toolkit.reclassify_overcapacity] : The ratio-based fallback when the spec signal is absent.
[`audit_static`][gbfs_toolkit.audit_static] : The A1-A7 audit whose A3 consumes the ``free_floating`` label.
Examples
--------
>>> import pandas as pd
>>> info = pd.DataFrame({
... "station_type": ["docked_bike", "docked_bike"],
... "is_virtual_station": [False, True],
... })
>>> classify_from_virtual_station(info)["station_type"].tolist()
['docked_bike', 'free_floating']
"""
require_columns(info, ["station_type"], what="classify_from_virtual_station")
out = info.copy()
if "is_virtual_station" not in out.columns:
return out
virtual = out["is_virtual_station"].fillna(False).astype(bool)
out.loc[virtual, "station_type"] = "free_floating"
return out
|