Stations.collect_locations¶
- Stations.collect_locations(initial, confirmation_required=True, verbose=False, raise_error=False)[source]¶
Collects data of railway station locations (mileages, operators and grid coordinates) for a given initial letter.
- Parameters:
initial (str) – The initial letter (e.g.
'a','z') of railway station names.confirmation_required (bool) – Whether user confirmation is required; if
confirmation_required=True(default), prompts the user for confirmation before proceeding with data collection.verbose (bool | int) – Whether to print relevant information to the console. Defaults to
True.raise_error (bool) – Whether to raise the provided exception; if
raise_error=False(default), the error will be suppressed.
- Returns:
A dictionary containing the data of railway station locations whose initial letters are the given
initialand 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_a_codes = stn.collect_locations(initial='a', verbose=True) Proceed with collecting data of "mileages, operators and grid coordinates" beginning.. [No]|Yes: yes Collecting the data ... Done. >>> type(stn_loc_a_codes) dict >>> list(stn_loc_a_codes) ['A', 'Last updated date'] >>> stn_loc_a_codes_df = stn_loc_a_codes['A'] >>> stn_loc_a_codes_df.shape (143, 15) >>> stn_loc_a_codes_df.head() Station Station Note ... CRS CRS Note 0 Abbey Wood ... ABW 1 Abbey Wood ... ABW 2 Aber ... ABE 3 Abercynon formerly 'Abercynon South' to 24 May 2008 ... ACY 4 Abercynon formerly 'Abercynon South' to 24 May 2008 ... ACY [5 rows x 15 columns] >>> stn_loc_a_codes_df[['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