Depots.fetch_pre_tops_codes

Depots.fetch_pre_tops_codes(update=False, dump_dir=None, verbose=False)[source]

Fetches the data of four-digit pre-TOPS 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 four-digit pre-TOPS codes and the date they were last updated.

Return type:

dict

Examples:

>>> from pyrcs.other_assets import Depots  # from pyrcs import Depots
>>> depots = Depots()
>>> fdpt_codes = depots.fetch_pre_tops_codes()
>>> type(fdpt_codes)
dict
>>> list(fdpt_codes.keys())
['Four digit pre-TOPS codes', 'Last updated date']
>>> depots.KEY_TO_PRE_TOPS
'Four digit pre-TOPS codes'
>>> fdpt_codes_dat = fdpt_codes[depots.KEY_TO_PRE_TOPS]
>>> type(fdpt_codes_dat)
pandas.core.frame.DataFrame
>>> fdpt_codes_dat.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