Stations.fetch_station_data

Stations.fetch_station_data(update=False, pickle_it=False, data_dir=None, verbose=False)[source]

Fetch railway station data from local backup.

Parameters
  • update (bool) – whether to check on update and proceed to update the package data, defaults to False

  • pickle_it (bool) – whether to replace the current package data with newly collected data, defaults to False

  • data_dir (str, None) – name of package data folder, defaults to None

  • verbose (bool, int) – whether to print relevant information in console as the function runs, defaults to False

Returns

railway station data (including the station name, ELR, mileage, status, owner, operator, degrees of longitude and latitude, and grid reference) and date of when the data was last updated

Return type

dict

Example:

>>> from pyrcs.other_assets import Stations

>>> stn = Stations()

>>> stn_data = stn.fetch_station_data()

>>> type(stn_data)
<class 'dict'>
>>> print(list(stn_data.keys()))
['Railway station data', 'Last updated date']

>>> stn_dat = stn_data['Railway station data']
>>> type(stn_dat)
<class 'pandas.core.frame.DataFrame'>
>>> print(stn_dat.head())
      Station   ELR   Mileage  ... Prev_Date_6 Prev_Operator_7  Prev_Date_7
0  Abbey Wood   NKL  11m 43ch  ...         NaN             NaN          NaN
1  Abbey Wood  XRS3  24.458km  ...         NaN             NaN          NaN
2        Aber   CAR   8m 69ch  ...         NaN             NaN          NaN
3   Abercynon   CAM  16m 28ch  ...         NaN             NaN          NaN
4   Abercynon   ABD  16m 28ch  ...         NaN             NaN          NaN

[5 rows x 25 columns]