apply_salmon_dictionary

apply_salmon_dictionary(df, dict_df, codes=None, strict=True)

Rename columns, coerce types, and apply codes using a validated dictionary.

A column a code list applies to becomes a Categorical whose categories are the list’s labels, from code_label, as metasalmon’s factor(levels = code_value, labels = code_label) gives them: two codes sharing a label share a category, and a code with no label becomes missing. Without a code_label column the code values are the labels.

A value that is not in its column’s code list has no category, so it becomes missing. Each such value is named in a RuntimeWarning, whatever strict is, because strict governs type coercion. Missing and blank values are not reported. As in metasalmon, a code list applies to a text or Categorical column; a numeric, logical or date column keeps its values. A matching codes row with a nonblank vocabulary_iri and a missing or blank code_value backs the whole column with a vocabulary instead of an enumerated code list. Such a column skips code labels and the unlisted value report, while its declared type and role still apply.

Back to top