Depots.collect_gwr_codes

Depots.collect_gwr_codes(confirmation_required=True, verbose=False, raise_error=False)[source]

Collect Great Western Railway (GWR) depot codes from the source web page.

Parameters:
  • 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 False.

  • raise_error (bool) – Whether to raise the provided exception; if raise_error=False (default), the error will be suppressed.

Returns:

A dictionary containing the GWR depot codes and the date they were last updated, or None if no data is collected.

Return type:

dict | None

Examples:

>>> from pyrcs.other_assets import Depots  # from pyrcs import Depots

>>> depots = Depots()

>>> gwr_codes = depots.collect_gwr_codes(verbose=True)
Proceed with collecting data of "GWR"?
 [No]|Yes: yes
Collecting the data ... Done.

>>> type(gwr_codes)
dict
>>> list(gwr_codes)
['GWR', 'Last updated date']

>>> gwr_codes_dat = gwr_codes['GWR']
>>> type(gwr_codes_dat)
dict
>>> list(gwr_codes_dat.keys())
['Alphabetical codes', 'Numerical codes', 'Keys to numerical codes']

>>> gwr_alpha_codes = gwr_codes_dat['Alphabetical codes']
>>> type(gwr_alpha_codes)
pandas.DataFrame
>>> gwr_alpha_codes.shape
(75, 2)
>>> gwr_alpha_codes.head()
    Code   Depot name
0  ABEEG     Aberbeeg
1    ABG     Aberbeeg
2    AYN    Abercynon
3   ABDR     Aberdare
4    ABH  Aberystwyth