spatial_outage_redundancy¶
spatial_outage_redundancy
¶
spatial_outage_redundancy(panel: DataFrame, *, radius_m: float = 300.0, time_col: str = 'fetched_at', value_col: str = 'num_bikes_available') -> DataFrame
Separate a station's local stockouts from systemic neighbourhood failures.
A station at zero bikes is not a service failure if a station 100 m away is full:
the user simply walks. The real rupture is spatial. For each station this reports
the share of time it is empty (local_outage_ratio) and the share of time it is
empty and every observed neighbour within radius_m is also empty
(systemic_outage_ratio), the fraction of outages that no nearby station can
absorb. A neighbour with no reading at that timestamp is treated as unknown (it
neither creates nor masks a systemic flag), and a timestamp needs at least one
observed neighbour to count. Repeated polls for the same station and timestamp are
de-duplicated (last kept), not summed. Purely descriptive: it reads observed stock,
it neither predicts demand nor reroutes anyone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel
|
DataFrame
|
Availability panel with |
required |
radius_m
|
float
|
Great-circle walking radius defining a station's substitutes. |
300.0
|
time_col
|
str
|
Timestamp and per-station available-bike column. |
'fetched_at'
|
value_col
|
str
|
Timestamp and per-station available-bike column. |
'fetched_at'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
See Also
station_outage_rates : The non-spatial stockout rate.
two_step_fca : Demand-weighted spatial accessibility.
coverage_stats : Areal coverage of the network.
Examples:
Station a is always empty, but only counts as a systemic outage when its
300 m neighbour b is empty too:
>>> import pandas as pd
>>> panel = pd.DataFrame({
... "station_id": ["a", "b", "a", "b"],
... "lat": [48.8500, 48.8501, 48.8500, 48.8501],
... "lon": [2.3500, 2.3501, 2.3500, 2.3501],
... "fetched_at": pd.to_datetime(
... ["2026-01-01T08:00Z", "2026-01-01T08:00Z",
... "2026-01-01T09:00Z", "2026-01-01T09:00Z"]),
... "num_bikes_available": [0, 5, 0, 0],
... })
>>> out = spatial_outage_redundancy(panel, radius_m=300).set_index("station_id")
>>> float(out.loc["a", "local_outage_ratio"]), float(out.loc["a", "systemic_outage_ratio"])
(1.0, 0.5)
Source code in src/gbfs_toolkit/spatial/analytics.py
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 | |