SignalBoxes.collect_prefix_codes¶
-
SignalBoxes.
collect_prefix_codes
(initial, update=False, verbose=False)[source]¶ Collect signal box prefix codes for the given
initial
from source web page.- Parameters
initial (str) – initial letter of signal box name (for specifying a target URL)
update (bool) – whether to check on update and proceed to update the package data, defaults to
False
verbose (bool, int) – whether to print relevant information in console as the function runs, defaults to
False
- Returns
data of signal box prefix codes for the given
initial
and date of when the data was last updated- Return type
dict
Example:
>>> from pyrcs.other_assets import SignalBoxes >>> sb = SignalBoxes() >>> signal_boxes_a = sb.collect_prefix_codes(initial='a') >>> type(signal_boxes_a) <class 'dict'> >>> print(list(signal_boxes_a.keys())) ['A', 'Last updated date'] >>> signal_boxes_a_codes = signal_boxes_a['A'] >>> type(signal_boxes_a_codes) <class 'pandas.core.frame.DataFrame'> >>> print(signal_boxes_a_codes.head()) Code Signal Box ... Closed Control to 0 AF Abbey Foregate Junction ... 1 AJ Abbey Junction ... 16 February 1992 Nuneaton (NN) 2 R Abbey Junction ... 16 February 1992 Nuneaton (NN) 3 AW Abbey Wood ... 13 July 1975 Dartford (D) 4 AE Abbey Works East ... 1 November 1987 Port Talbot (PT) [5 rows x 8 columns]