fetch_location_names_errata¶
- pyrcs.utils.fetch_location_names_errata(k=None, regex=False, as_dataframe=False, column_name=None)[source]¶
Fetches a dictionary or dataframe to rectify location names.
- Parameters:
k (str | int | float | bool | None) – The key for the errata dictionary; defaults to
None
.regex (bool) – Whether to create the dictionary for replacements based on regular expressions; defaults to
False
.as_dataframe (bool) – Whether to return the dictionary as a dataframe; defaults to
False
.column_name (str | list | None) – If
as_dataframe=True
, the column name for the dataframe; defaults toNone
.
- Returns:
A dictionary for rectifying location names, or a dataframe if requested.
- Return type:
dict | pandas.DataFrame
Examples:
>>> from pyrcs.utils import fetch_location_names_errata >>> repl_dict = fetch_location_names_errata() >>> type(repl_dict) dict >>> list(repl_dict.keys())[:5] ['"Tyndrum Upper" (Upper Tyndrum)', 'AISH EMERGENCY CROSSOVER', 'ATLBRJN', 'Aberdeen Craiginches', 'Aberdeen Craiginches T.C.'] >>> repl_dict = fetch_location_names_errata(regex=True, as_dataframe=True) >>> type(repl_dict) pandas.core.frame.DataFrame >>> repl_dict.head() new_value re.compile(' \(DC lines\)') [DC lines] re.compile(' And | \+ ') & re.compile('-By-') -by- re.compile('-In-') -in- re.compile('-En-Le-') -en-le-