Stations.fetch_locations¶
- Stations.fetch_locations(update=False, dump_dir=None, verbose=False)[source]¶
Fetches the data of railway station locations (mileages, operators and grid coordinates).
- 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 railway station locations and the date of when the data was last updated.
- Return type:
dict
Examples:
>>> from pyrcs.other_assets import Stations # from pyrcs import Stations >>> stn = Stations() >>> stn_loc_codes = stn.fetch_locations() >>> type(stn_loc_codes) dict >>> list(stn_loc_codes.keys()) ['Mileages, operators and grid coordinates', 'Last updated date'] >>> stn.KEY_TO_STN 'Mileages, operators and grid coordinates' >>> stn_loc_codes_dat = stn_loc_codes[stn.KEY_TO_STN] >>> type(stn_loc_codes_dat) pandas.core.frame.DataFrame >>> stn_loc_codes_dat.head() Station ... Former Operator 0 Abbey Wood ... London & South Eastern Railway from 1 April 20... 1 Abbey Wood ... London & South Eastern Railway from 1 April 20... 2 Aber ... Keolis Amey Operations/Gweithrediadau Keolis A... 3 Abercynon ... Keolis Amey Operations/Gweithrediadau Keolis A... 4 Abercynon ... Keolis Amey Operations/Gweithrediadau Keolis A... [5 rows x 14 columns] >>> stn_loc_codes_dat.columns.to_list() ['Station', 'Station Note', 'ELR', 'Mileage', 'Status', 'Degrees Longitude', 'Degrees Latitude', 'Grid Reference', 'CRS', 'CRS Note', 'Owner', 'Former Owner', 'Operator', 'Former Operator'] >>> stn_loc_codes_dat[['Station', 'ELR', 'Mileage']].head() Station ELR Mileage 0 Abbey Wood NKL 11m 43ch 1 Abbey Wood XRS 24.458km 2 Aber CAR 8m 69ch 3 Abercynon CAM 16m 28ch 4 Abercynon ABD 16m 28ch