build_availability_panel¶
build_availability_panel
¶
build_availability_panel(base_path: str | Path, *, system_id: str | None = None, start_time: str | Timestamp | None = None, end_time: str | Timestamp | None = None, resample_freq: str | None = None, dedup: bool = True, columns: list[str] | None = None, filters: Any = None, target_tz: str | None = None) -> DataFrame
Read a partitioned dataset into a tidy availability panel.
Filters by system_id and the date partition before loading (memory-bounded),
then de-duplicates redundant polls (same station_id + last_reported) and
optionally resamples each station to a fixed frequency (forward-filled).
Scaling to large lakes
For multi-month / multi-city panels that would not fit in memory, push the work down into PyArrow:
columns: project only the columns you need (the keyssystem_id,station_id,fetched_atand, when de-duplicating,last_reportedare always read). Fewer columns ⇒ less I/O and RAM.filters: an extrapyarrow.datasetpredicate ANDed with the built-in system/date filter, applied before materialising (row-group pruning). Build it withimport pyarrow.dataset as ds; ds.field("num_bikes_available") == 0.
Local time
Pass target_tz (e.g. "America/Los_Angeles") to convert fetched_at /
last_reported to that zone before any dedup or resample. Resampling tz-aware UTC
data would otherwise cut "days" at UTC midnight (i.e. mid-afternoon local time),
silently corrupting diurnal/daily aggregations.
Returns:
| Type | Description |
|---|---|
DataFrame
|
MultiIndexed by |
See Also
availability : A single-snapshot availability frame.
calculate_net_flow : Per-interval flow from this panel.
stockout_episodes : Outage episodes from this panel.
Source code in src/gbfs_toolkit/io/timeseries.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 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 183 184 185 186 187 188 189 | |