temporal_autocorrelation¶
temporal_autocorrelation
¶
temporal_autocorrelation(panel: DataFrame, *, lags: tuple[int, ...] = (1, 24, 168), freq: str = '1h', value_col: str = 'num_bikes_available', column: str | None = None) -> DataFrame
Per-station autocorrelation of availability at fixed lags (hour, day, week).
Each station's series is resampled to freq (mean) and correlated with itself at each
lag. High autocorrelation at lag 24 (one day) marks a regular commuter rhythm; low
autocorrelation everywhere marks an irregular or recreational station. A deterministic,
descriptive precursor to (or substitute for) clustering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel
|
DataFrame
|
From |
required |
lags
|
tuple of int
|
Lags in units of |
(1, 24, 168)
|
freq
|
str
|
Resampling frequency. |
"1h"
|
value_col
|
str
|
Series to correlate. |
"num_bikes_available"
|
column
|
str
|
Deprecated alias for |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
References
O'Brien, Cheshire and Batty (2014), Mining bike-sharing data for sustainable transport.
See Also
diurnal_summary_stats : The diurnal curve behind the rhythm.
availability_synchrony : Cross-station correlation network.
Examples:
>>> import pandas as pd
>>> idx = pd.date_range("2026-01-01", periods=6, freq="1h", tz="UTC")
>>> panel = pd.DataFrame({
... "system_id": "s", "station_id": "a", "fetched_at": idx,
... "num_bikes_available": [0, 5, 0, 5, 0, 5],
... })
>>> round(float(temporal_autocorrelation(panel, lags=(2,))["acf_lag_2"].iloc[0]), 1)
1.0