Stations.collect_locations_by_initial

Stations.collect_locations_by_initial(initial, update=False, verbose=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.

  • update (bool) – Whether to check for updates to the package data; defaults to False.

  • verbose (bool | int) – Whether to print relevant information to the console; defaults to True.

Returns:

A dictionary containing the data of railway station locations whose initial letters are the given initial and 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_by_initial(initial='a')
>>> type(stn_loc_a_codes)
dict
>>> list(stn_loc_a_codes.keys())
['A', 'Last updated date']
>>> stn_loc_a_codes_dat = stn_loc_a_codes['A']
>>> type(stn_loc_a_codes_dat)
pandas.core.frame.DataFrame
>>> stn_loc_a_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_a_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_a_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