clean_label

clean_label(x, prefix=None)

Tidy an exported column name into a readable label.

Turns the mangled column names survey tools produce back into the wording a reader expects: “Broadcast.quality…audio” becomes “Broadcast quality / audio”. Drop a question prefix at the same time with prefix, so a block of ratings_* columns becomes plain feature names.

Exporters replace every character they cannot put in a column name with a dot, so a slash surrounded by spaces arrives as three dots and a space arrives as one. This restores both, in that order, then squishes the result. It is the same cleaning calc_percentage_multi() and ipm_model() apply to their own output, so a hand-built table can match them.

Parameters

Name Type Description Default
x str or list of str Column names. required
prefix str Prefix to strip from the start of each name before tidying, e.g. “ratings_”. Names that do not start with it are left alone. None

Returns

Name Type Description
list of str Labels, the same length as x.

See Also

calc_percentage_batch, calc_percentage_multi

Examples

>>> clean_label("Broadcast.quality...audio")
>>> clean_label(["ratings_Camera.work", "ratings_Talent...analysis"], prefix="ratings_")