Depots.fetch_codes

Depots.fetch_codes(update=False, dump_dir=None, verbose=False, **kwargs)[source]

Fetch data of depot codes.

Parameters:
  • 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 depot codes and the date they were last updated.

Return type:

dict

Examples:

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

>>> depots = Depots()

>>> depots_codes = depots.fetch_codes()
>>> type(depots_codes)
dict
>>> list(depots_codes)
['Depots', 'Last updated date']

>>> depots.KEY
'Depots'

>>> depots_codes_dat = depots_codes[depots.KEY]
>>> type(depots_codes_dat)
dict
>>> list(depots_codes_dat)
['1950 system (pre-TOPS)', 'GWR', 'Four digit pre-TOPS', 'Two character TOPS']

>>> depots.KEY_TO_PRE_TOPS
'Four digit pre-TOPS'
>>> depots_codes_dat[depots.KEY_TO_PRE_TOPS].shape
(950, 4)
>>> depots_codes_dat[depots.KEY_TO_PRE_TOPS].head()
   Code             Depot name          Region  Main Works site
0  2000             Accrington  London Midland            False
1  2001   Derby Litchurch Lane  London Midland             True
2  2003              Blackburn  London Midland            False
3  2004  Bolton Trinity Street  London Midland            False
4  2006                Burnley  London Midland            False

>>> depots.KEY_TO_TOPS
'Two character TOPS'
>>> depots_codes_dat[depots.KEY_TO_TOPS].shape
(591, 5)
>>> depots_codes_dat[depots.KEY_TO_TOPS].head()
  Code  ...                Notes
0   AB  ...          Closed 1987
1   AB  ...
2   AC  ...  Became WH from 1994
3   AC  ...
4   AD  ...
[5 rows x 5 columns]