Tunnels.fetch_codes

Tunnels.fetch_codes(update=False, dump_dir=None, verbose=False)

Fetch data of railway tunnel lengths.

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 railway tunnel lengths (including the name, length, owner and relative location) and date of when the data was last updated

Return type

dict

Examples:

>>> from pyrcs.other_assets import Tunnels  # from pyrcs import Tunnels

>>> tunl = Tunnels()

>>> tunl_len_codes = tunl.fetch_codes()
>>> type(tunl_len_codes)
dict
>>> list(tunl_len_codes.keys())
['Tunnels', 'Last updated date']

>>> tunl.KEY
'Tunnels'

>>> tunl_len_codes_dat = tunl_len_codes[tunl.KEY]
>>> type(tunl_len_codes_dat)
dict
>>> list(tunl_len_codes_dat.keys())
['Page 1 (A-F)', 'Page 2 (G-P)', 'Page 3 (Q-Z)', 'Page 4 (others)']

>>> page_1_codes = tunl_len_codes_dat['Page 1 (A-F)']
>>> type(page_1_codes)
pandas.core.frame.DataFrame
>>> page_1_codes.head()
             Name  Other names, remarks  ... Length (metres) Length (note)
0    Abbotscliffe                        ...       1775.7648
1      Abercanaid           see Merthyr  ...             NaN   Unavailable
2     Aberchalder         see Loch Oich  ...             NaN   Unavailable
3  Aberdovey No 1  also called Frongoch  ...        182.8800
4  Aberdovey No 2    also called Morfor  ...        200.2536
[5 rows x 10 columns]

>>> page_4_codes = tunl_len_codes_dat['Page 4 (others)']
>>> type(page_4_codes)
dict
>>> list(page_4_codes.keys())
['Tunnels on industrial and other minor lines',
 'Large bridges that are not officially tunnels but could appear to be so']

>>> key1 = 'Tunnels on industrial and other minor lines'
>>> page_4_dat = page_4_codes[key1]
>>> type(page_4_dat)
pandas.core.frame.DataFrame
>>> page_4_dat.head()
                      Name Other names, remarks  ... Length (metres) Length (note)
0             Ashes Quarry                       ...         56.6928
1        Ashey Down Quarry                       ...         33.8328
2  Baileycroft Quarry No 1                       ...         28.3464
3  Baileycroft Quarry No 2                       ...         21.0312
4            Basfords Hill                       ...         46.6344
[5 rows x 6 columns]

>>> key2 = 'Large bridges that are not officially tunnels but could appear to be so'
>>> page_4_dat_ = page_4_codes[key2]
>>> type(page_4_dat_)
pandas.core.frame.DataFrame
>>> page_4_dat_.head()
                Name Other names, remarks  ... Length (metres) Length (note)
0  A470/A472 (north)                       ...         35.6616
1  A470/A472 (south)                       ...         28.3464
2               A720                       ...        145.3896
3                 A9        Aberdeen line  ...        141.7320
4                 A9           Perth line  ...        146.3040
[5 rows x 8 columns]