krank.fetch_lexicon#
- krank.fetch_lexicon(dataset, version=None, load=True, **kwargs)#
Fetch a lexicon as a
pandas.DataFrame.Calling this function will always retrieve/download the file from its remote source if it has not already been retrieved (via
pooch.retrieve()).Refer to the online
krank.lexiconsdocumentation for more details about the module and available lexicons.Note
Custom loading
To apply custom loading, either (1) set
load=Falseto return the local filepath and load the file in subsequent steps, or (2) pass a callable function toloadand it will be used to load the file instead of thekrankdefault loader.See also
This is a top-level wrapper around dataset-specific functions in the
krank.lexiconsmodule. For example, callingkrank.fetch_lexicon("threat")is identical to callingkrank.tables.fetch_threat().Parameters#
- datasetstr
Name of dataset (i.e., lexicon). Refer to the
lexiconsdocumentation for a list of all available datasets.- versionstr or None
Name of version. If
None(default), fetches the latest version. Refer to thelexiconsdocumentation for a list of all available versions within each dataset.- loadbool or callable
If
False(default), fetch the file and return the local filepath. IfTrue, fetch the file and load it as apandas.DataFrame. If a callable, fetch the file an load it with the custom callable.- **kwargsdict, optional
Additional keyword arguments are passed to
pooch.retrieve().
Returns#
- str or
DataFrame Path of retrieved file if
loadis False, orpandas.DataFrameifloadis True.