SignalBoxes.collect_prefix_codes¶
- SignalBoxes.collect_prefix_codes(initial, update=False, verbose=False)[source]¶
Collects signal box prefix codes starting with a given initial letter from the source web page.
- Parameters:
initial (str) – The initial letter (e.g.
'a'
,'z'
) of signal box prefix code.update (bool) – Whether to check for updates to the package data; defaults to
False
.verbose (bool | int) – Whether to print relevant information to the console; defaults to
True
.
- Returns:
A dictionary containing data of signal box prefix codes whose initial letters are the specified
initial
and the date of when the data was last updated.- Return type:
dict
Examples:
>>> from pyrcs.other_assets import SignalBoxes # from pyrcs import SignalBoxes >>> sb = SignalBoxes() >>> sb_a_codes = sb.collect_prefix_codes(initial='a') >>> type(sb_a_codes) dict >>> list(sb_a_codes.keys()) ['A', 'Last updated date'] >>> sb_a_codes_dat = sb_a_codes['A'] >>> type(sb_a_codes_dat) pandas.core.frame.DataFrame >>> sb_a_codes_dat.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]