SignalBoxes.collect_bell_codes¶
- SignalBoxes.collect_bell_codes(confirmation_required=True, verbose=False)[source]¶
Collects data of bell codes 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 data of bell codes 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() >>> sb_bell_codes = sb.collect_bell_codes() To collect data of Bell codes ? [No]|Yes: yes >>> type(sb_bell_codes) dict >>> list(sb_bell_codes.keys()) ['Bell codes', 'Last updated date'] >>> sb.KEY_TO_BELL_CODES 'Bell codes' >>> sb_bell_codes_dat = sb_bell_codes[sb.KEY_TO_BELL_CODES] >>> type(sb_bell_codes_dat) collections.OrderedDict >>> list(sb_bell_codes_dat.keys()) ['Network Rail codes', 'Southern Railway codes', 'Lancashire & Yorkshire Railway codes'] >>> sb_nr_bell_codes = sb_bell_codes_dat['Network Rail codes'] >>> type(sb_nr_bell_codes) dict >>> list(sb_nr_bell_codes.keys()) ['Codes', 'Notes'] >>> sb_nr_bell_codes_dat = sb_nr_bell_codes['Codes'] >>> type(sb_nr_bell_codes_dat) pandas.core.frame.DataFrame >>> sb_nr_bell_codes_dat.head() Code Meaning 0 1 Call attention 1 1-1 Answer telephone [withdrawn 2007] 2 1-1-6 Police assistance urgently required 3 1-2 Signaller required on telephone [added 2007] 4 1-2-1 Train approaching