Depots.collect_tops_codes¶
- Depots.collect_tops_codes(confirmation_required=True, verbose=False, raise_error=False)[source]¶
Collect two-character TOPS 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 two-character TOPS codes and the date they were last updated, or
Noneif no data is collected.- Return type:
dict | None
Examples:
>>> from pyrcs.other_assets import Depots # from pyrcs import Depots >>> depots = Depots() >>> tct_codes = depots.collect_tops_codes(verbose=True) Proceed with collecting data of "two character tops"? [No]|Yes: yes Collecting the data ... Done. >>> type(tct_codes) dict >>> list(tct_codes) ['Two character TOPS', 'Last updated date'] >>> tct_codes_dat = tct_codes['Two character TOPS'] >>> type(tct_codes_dat) pandas.DataFrame >>> tct_codes_dat.shape (591, 5) >>> tct_codes_dat.head() Code ... Notes 0 AB ... closed 1987 1 AB ... 2 AC ... became WH from 1994 3 AC ... 4 AD ... [5 rows x 5 columns]