RenamePlan#
- class scikitplot.feature_selection.RenamePlan(pairs)[source]#
A complete, frozen
old -> newname mapping.- Parameters:
- pairstuple of (str, str)
One pair per input column, in column order.
- Parameters:
See also
FeatureRenamerApplies a plan inside a pipeline.
FeatureSchema.renameRenames a fitted schema, keeping aliases.
Examples
>>> from scikitplot.feature_selection import RenamePlan >>> RenamePlan.build(["a", "b", "c"], "col-{index}", start=1).names_out ['col-1', 'col-2', 'col-3'] >>> RenamePlan.build(["a", "b"], {"a": "alpha"}).names_out ['alpha', 'b'] >>> RenamePlan.build(["x", "y"], str.upper).mapping {'x': 'X', 'y': 'Y'}
- classmethod build(names, rule, *, start=0, on_collision='raise', on_missing='raise')[source]#
Apply
ruletonamesonce and freeze the result.- Parameters:
- namessequence of str
Input column names (unique).
- rulemapping, sequence of str, callable, str or None
See the module documentation. None keeps every name.
- startint, default=0
First
{index}of a template.- on_collision{“raise”, “suffix”}, default=”raise”
Handling of duplicate new names.
- on_missing{“raise”, “ignore”}, default=”raise”
Handling of mapping keys that are not in
names.
- Returns:
- RenamePlan
The plan.
- Raises:
- ValueError
For a list of the wrong length, an unknown template field, an unknown mapping key, an empty new name or a refused collision.
- TypeError
For a rule of an unsupported type or a callable returning a non-string.
- Parameters:
- Return type:
- classmethod from_dict(data)[source]#
Rebuild a plan from
to_dictoutput.- Parameters:
- datamapping
Stored form.
- Returns:
- RenamePlan
The plan.
- Parameters:
- Return type: