SignalBoxes.collect_non_national_rail_codes

SignalBoxes.collect_non_national_rail_codes(confirmation_required=True, verbose=False)[source]

Collects the signal box prefix codes for non-national rail from the source web page.

Parameters:
  • confirmation_required (bool) – Whether user confirmation is required before proceeding; defaults to True.

  • verbose (bool | int) – Whether to print relevant information to the console; defaults to False.

Returns:

A dictionary containing the signal box prefix codes for non-national rail and the date when they were last updated, or None if no data is collected.

Return type:

dict | None

Examples:

>>> from pyrcs.other_assets import SignalBoxes  # from pyrcs import SignalBoxes
>>> sb = SignalBoxes()
>>> nnr_codes = sb.collect_non_national_rail_codes()
To collect data of non-national rail signal box prefix codes
? [No]|Yes: yes
>>> type(nnr_codes)
dict
>>> list(nnr_codes.keys())
['Non-National Rail', 'Last updated date']
>>> sb.KEY_TO_NON_NATIONAL_RAIL
'Non-National Rail'
>>> nnr_codes_dat = nnr_codes[sb.KEY_TO_NON_NATIONAL_RAIL]
>>> type(nnr_codes_dat)
dict
>>> list(nnr_codes_dat.keys())
['Croydon Tramlink signals',
 'Docklands Light Railway signals',
 'Edinburgh Tramway signals',
 'Glasgow Subway signals',
 'London Underground signals',
 'Luas signals',
 'Manchester Metrolink signals',
 'Midland Metro signals',
 'Nottingham Tram signals',
 'Sheffield Supertram signals',
 'Tyne & Wear Metro signals',
 "Heritage, minor and miniature railways and other 'special' signals"]
>>> lu_signals_codes = nnr_codes_dat['London Underground signals']
>>> type(lu_signals_codes)
dict
>>> list(lu_signals_codes.keys())
['Codes', 'Notes']
>>> type(lu_signals_codes['Codes'])
pandas.core.frame.DataFrame
>>> lu_signals_codes['Codes'].head()
  Code  ... Became or taken over by (where known)
0  BMX  ...                                     -
1    A  ...                                     -
2    S  ...                                     -
3    X  ...                                     -
4    R  ...                                     -
[5 rows x 5 columns]