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

>>> # rail_stn_data = stn.fetch_station_data(update=True, verbose=True)
>>> rail_stn_data = stn.fetch_station_data()

>>> type(rail_stn_data)
dict
>>> list(rail_stn_data.keys())
['Railway station data', 'Last updated date']

>>> rail_stn_dat = rail_stn_data['Railway station data']

>>> type(rail_stn_dat)
pandas.core.frame.DataFrame
>>> print(rail_stn_dat.head())
         Station   ELR  ... Prev_Operator_6 Prev_Operator_Period_6
2606              MRL1  ...            None                   None
723                TAT  ...            None                   None
89                 ABD  ...            None                   None
90                 CAM  ...            None                   None
85    Abbey Wood   NKL  ...            None                   None
[5 rows x 32 columns]