Features.fetch_telegraph_codes

Features.fetch_telegraph_codes(update=False, dump_dir=None, verbose=False)[source]

Fetches the data of telegraph code words.

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 telegraph code words and the date they were last updated.

Return type:

dict

Examples:

>>> from pyrcs.other_assets import Features  # from pyrcs import Features
>>> feats = Features()
>>> tel_codes = feats.fetch_telegraph_codes()
>>> type(tel_codes)
dict
>>> list(tel_codes.keys())
['Telegraphic codes', 'Last updated date']
>>> feats.KEY_TO_TELEGRAPH
'Telegraphic codes'
>>> tel_codes_dat = tel_codes[feats.KEY_TO_TELEGRAPH]
>>> type(tel_codes_dat)
dict
>>> list(tel_codes_dat.keys())
['Official codes', 'Unofficial codes']
>>> tel_official_codes = tel_codes_dat['Official codes']
>>> type(tel_official_codes)
pandas.core.frame.DataFrame
>>> tel_official_codes.head()
      Code  ...                               In use
0    ABACK  ...     cross industry term used in 1939
1    ABASE  ...                            GWR, 1939
2  ABREAST  ...  GWR, 1939 / Railway Executive, 1950
3  ABREAST  ...   British Transport Commission, 1958
4   ABSENT  ...                            GWR, 1939
[5 rows x 3 columns]
>>> tel_unofficial_codes = tel_codes_dat['Unofficial codes']
>>> type(tel_unofficial_codes)
pandas.core.frame.DataFrame
>>> tel_unofficial_codes.head()
      Code                             Unofficial description
0  CRANKEX                                      [See KRANKEX]
1  DRUNKEX  Saturday night special train (usually a DMU) t...
2     GYFO    Strongly urge all speed ('Get your finger out')
3  KRANKEX  Special train with interesting routing or trac...
4   MYSTEX  Special excursion going somewhere no one reall...