SignalBoxes.collect_prefix_codes

SignalBoxes.collect_prefix_codes(initial, update=False, verbose=False)

Collect signal box prefix codes beginning with a given initial letter from source web page.

Parameters
  • initial (str) – initial letter of signal box name (for specifying a target URL)

  • update (bool) – whether to do an update check (for the package data), defaults to False

  • verbose (bool or int) – whether to print relevant information in console, defaults to False

Returns

data of signal box prefix codes beginning with the given initial letter and 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]