Features.fetch_telegraph_codes

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

Fetch data of telegraph code words.

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

  • dump_dir (str or None) – name of a folder where the pickle file is to be saved, defaults to None

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

Returns

data of telegraph code words, and date of when the data was 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...