fetch_location_names_errata

pyrcs.utils.fetch_location_names_errata(k=None, regex=False, as_dataframe=False, column_name=None)

Create a dictionary for rectifying location names.

Parameters
  • k (str or int or float or bool or None) – key of the created dictionary, defaults to None

  • regex (bool) – whether to create a dictionary for replacement based on regular expressions, defaults to False

  • as_dataframe (bool) – whether to return the created dictionary as a pandas.DataFrame, defaults to False

  • column_name (str or list or None) – (if as_dataframe=True) column name of the errata data as a dataframe

Returns

dictionary for rectifying location names

Return type

dict or 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-