Tunnels.collect_codes_by_page
- Tunnels.collect_codes_by_page(page_no, update=False, verbose=False)
Collect data of railway tunnel lengths for a page number from source web page.
- Parameters
page_no (int or str) – page number; valid values include
1
,2
,3
and4
update (bool) – whether to do an update check (for the package data), defaults to
False
verbose (bool or int) – whether to print relevant information in console, defaults to
False
- Returns
data of tunnel lengths on page
page_no
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_1 = tunl.collect_codes_by_page(page_no=1) >>> type(tunl_len_1) dict >>> list(tunl_len_1.keys()) ['Page 1 (A-F)', 'Last updated date'] >>> tunl_len_1_codes = tunl_len_1['Page 1 (A-F)'] >>> type(tunl_len_1_codes) pandas.core.frame.DataFrame >>> tunl_len_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 11 columns] >>> tunl_len_4 = tunl.collect_codes_by_page(page_no=4) >>> type(tunl_len_4) dict >>> list(tunl_len_4.keys()) ['Page 4 (others)', 'Last updated date'] >>> tunl_len_4_codes = tunl_len_4['Page 4 (others)'] >>> type(tunl_len_4_codes) dict >>> list(tunl_len_4_codes.keys()) ['Tunnels on industrial and other minor lines', 'Large bridges that are not officially tunnels but could appear to be so'] >>> tunl_len_4_dat = tunl_len_4_codes['Tunnels on industrial and other minor lines'] >>> type(tunl_len_4_dat) pandas.core.frame.DataFrame >>> tunl_len_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]