LOR.get_keys_to_prefixes¶
- LOR.get_keys_to_prefixes(prefixes_only=True, update=False, dump_dir=None, verbose=False, **kwargs)[source]¶
Extract the keys to PRIDE/LOR code prefixes.
This method retrieves regional prefix information from a local cache or a live platform endpoint, with an option to filter and return only the prefix strings.
- Parameters:
prefixes_only (bool) – Whether to return only the list of prefixes. Defaults to
True.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 list of the keys to LOR code prefixes if
prefixes_only=True, otherwise a dictionary containing code prefixes and the last updated date, orNoneif no data is available.- Return type:
list | dict | None
Examples:
>>> from pyrcs.line_data import LOR # from pyrcs import LOR >>> lor = LOR() >>> keys_to_prefixes = lor.get_keys_to_prefixes() >>> keys_to_prefixes ['CY', 'EA', 'GW', 'LN', 'MD', 'NW', 'NZ', 'SC', 'SO', 'SW', 'XR'] >>> keys_to_prefixes = lor.get_keys_to_prefixes(prefixes_only=False) >>> list(keys_to_prefixes.keys()) ['Key to prefixes', 'Last updated date'] >>> keys_to_prefixes_data = keys_to_prefixes['Key to prefixes'] >>> type(keys_to_prefixes_data) pandas.DataFrame >>> keys_to_prefixes_data.head() prefixes name 0 CY Wales 1 EA South Eastern: East Anglia area 2 EX generic/example 3 GW Great Western (later known as Western) 4 LN London & North Eastern