funpack.schema.coding
This module contains the loadCodingFile() function, which can be used
to load descriptions of the values for a given data coding.
The data coding information for data codings in the UKBiobank is downloaded
from the UK Biobank showcase at
https://biobank.ctsu.ox.ac.uk/crystal/schema.cgi. Some pre-downloaded backup
files are stored in in funpack/schema/coding/.
- funpack.schema.coding.getCoding(dtable=None, vid=None, coding=None)[source]
Return a data coding ID for the given
vidorcoding. See theloadCodingFile()function for details.- Parameters:
dtable – The
DataTablevid – The variable ID
coding – Data coding ID
- Returns:
An integer ID for the corresponding data coding.
- funpack.schema.coding.getCodingFilePath(coding)[source]
Return a file path to a backup file for the given coding. The file is not guaranteed to exist.
- funpack.schema.coding.loadCodingFile(dtable=None, vid=None, coding=None, download=True)[source]
Loads a UK Biobank data coding scheme.
Coding files can be looked up with one of the following methods, in order of precedence:
By specifying a data coding (
coding). This takes precedence.By passing a
DataTable(dtable) and variable ID (vid)
The descriptions are returned in a
pandas.DataFrame, with the coding values as the index, and a single column calledmeaning, containing the descriptions for each value.- Parameters:
dtable – The
DataTablevid – Variable ID
coding – Data coding ID
download – Defaults to
True- coding files are downloaded from the UK Biobank showcase. Set toFalseto force loading from the backup files infunpack/schema/coding/.
- Returns:
A
DataFramecontaining descriptions