Depots.fetch_codes¶
- Depots.fetch_codes(update=False, dump_dir=None, verbose=False)[source]¶
Fetches the 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.keys()) ['Depots', 'Last updated date'] >>> depots.KEY 'Depots' >>> depots_codes_dat = depots_codes[depots.KEY] >>> type(depots_codes_dat) dict >>> list(depots_codes_dat.keys()) ['1950 system (pre-TOPS) codes', 'Four digit pre-TOPS codes', 'GWR codes', 'Two character TOPS codes'] >>> depots.KEY_TO_PRE_TOPS 'Four digit pre-TOPS codes' >>> 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 codes' >>> 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]