Stations.fetch_locations

Stations.fetch_locations(initial=None, update=False, dump_dir=None, verbose=False, **kwargs)[source]

Fetches data of railway station locations (mileages, operators and grid coordinates).

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.

  • 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()

>>> list(stn_loc_codes)
['Mileages, operators and grid coordinates', 'Last updated date']

>>> stn_loc_codes_df = stn_loc_codes['Mileages, operators and grid coordinates']
>>> stn_loc_codes_df.shape
(2932, 15)
>>> stn_loc_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_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