availability_synchrony¶
availability_synchrony
¶
availability_synchrony(panel: DataFrame, *, value_col: str = 'num_bikes_available', freq: str = '1h', method: str = 'pearson', min_overlap: int = 24, threshold: float | None = None) -> DataFrame
Pairwise correlation of station availability series: a functional synchrony network.
Resamples each station to freq and correlates every pair over their common support
(requiring min_overlap shared observations), returning the upper-triangle edge list.
This is the descriptive adjacency that precedes community detection of co-fluctuating stations.
It correlates observed availability only; it infers no trips and no direction (no OD). Bring
your own graph library (NetworkX, igraph) for the network analysis itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel
|
DataFrame
|
From |
required |
freq
|
str
|
Resampling bin for the per-station series. |
"1h"
|
method
|
('pearson', 'spearman', 'kendall')
|
Correlation method. |
"pearson"
|
min_overlap
|
int
|
Minimum shared observations for a pair to be reported. |
24
|
threshold
|
float
|
If given, keep only edges with |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
References
O'Brien, Cheshire and Batty (2014); the functional-connectivity correlation-network idiom.
See Also
temporal_autocorrelation : Per-station rhythm regularity.
Examples:
>>> import pandas as pd
>>> idx = pd.date_range("2026-01-01", periods=3, freq="1h", tz="UTC")
>>> panel = pd.DataFrame({
... "station_id": ["a"] * 3 + ["b"] * 3,
... "fetched_at": list(idx) * 2,
... "num_bikes_available": [1, 2, 3, 2, 4, 6],
... })
>>> round(float(availability_synchrony(panel, min_overlap=3)["corr"].iloc[0]), 1)
1.0
Source code in src/gbfs_toolkit/analytics/temporal.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |