SignalBoxes.fetch_bell_codes

SignalBoxes.fetch_bell_codes(update=False, dump_dir=None, verbose=False)[source]

Fetches the data of bell codes.

Parameters:
  • update (bool) – Whether to check for updates to the package data; defaults to False.

  • dump_dir (str | None) – The path to a directory where the data file will be saved; defaults to None.

  • 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.

Return type:

dict

Examples:

>>> from pyrcs.other_assets import SignalBoxes  # from pyrcs import SignalBoxes
>>> sb = SignalBoxes()
>>> sb_bell_codes = sb.fetch_bell_codes()
>>> 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